Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Validation multiple selectors for ignore

I am running into a problem with jQuery Validation and need to ignore some fields.

I need to ignore fields based on a class that I set and then also all hidden fields. What I need to do is the following, but it is only honoring the second ignore. I am assuming there is a way to tell jQuery Validation these multiple selectors but I cannot seem to find it.

validator = $("#form1").validate({
    onsubmit: false,
    ignore: ".ignore",
    ignore: ":hidden",

Thanks,

Tim

like image 436
divtag Avatar asked Oct 24 '12 13:10

divtag


1 Answers

From the validation documentation:

jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option.

Therefore all you need to do is pass one parameter with your selectors separated by commas:

validator = $("#form1").validate({
    onsubmit: false,
    ignore: ".ignore, :hidden"
});
like image 188
Rory McCrossan Avatar answered Sep 28 '22 03:09

Rory McCrossan