JQuery validation rule depends on another rule -


i have form required field depend on form field value. required rule may true or false depend on other field. issue accept rule should there if required true. how can that?

..., fielda: {      maxlength: 3,      accept: "[0-9]{3}",      required: function() {           if($('#fieldb').val() == 'abcd') {                return false;           } else {                return true;           }      } },... 

thanks in advance.

i didn't realize 'accept' rule custom rule. edited code check whether optional field. this.optional(element)

jquery.validator.addmethod("accept", function(value, element, param) {     return this.optional(element) || value.match(new regexp("^" + param + "$")); }); 

@barmar help.


Comments

Popular posts from this blog

c++ - list<myClass<int> * > sort -

SoapUI on windows 10 - high DPI/4K scaling issue -

java - why am i getting a "cannot resolve method" error on getApplication? -