dstreet / dependsOn

a jQuery plugin for handling form field dependencies
http://dstreet.github.com/dependsOn
MIT License
106 stars 32 forks source link

Enable based on any value entered in preceding text field #2

Closed onshop closed 9 years ago

onshop commented 10 years ago

Great plugin. Just what I was looking for. A nice extra in the configuration would be whether a preceding text field has any value at all. I tried not: [''] but that didn't seem to work. Maybe an 'empty' boolean qualifier could be added.

dstreet commented 10 years ago

Thanks, @onshop. I'm glad its working out for you. Adding an empty qualifier is a great idea. I'll probably add that to the next release, or feel free to submit at PR. The not qualifier should work fine to enable a subject when the dependency's value is not an empty string. However, if you want to enable the subject only when the dependency's value is an empty string you could use the match qualifier, which checks the value against a regular expression. In this case, you could use the regex \.+\.

onshop commented 10 years ago

Thanks for the workaround @dstreet. I'll give that a try.

onshop commented 9 years ago

My current workaround:

deadLineDate = $("#deadlineDate").dependsOn({
    #deadline_reason': {
        match: /\S/
     }
 }, {
     hide: false,
 });

$( "#deadline_reason" ).keyup(function() {
    deadLineDate.check();
});