Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Validate dynamically change ignore rule

I have a simple validate block like this:

$("#myForm").validate({
     ignore: ":hidden"
});

When the user clicks a certain button, I would like to change that ignore rule to ignore: [] , then validate it and then switch back. I realize I could use classes instead but I want to know if there is a way around that.

Edit: It should be noted that ignore: [] is the proper way to do it when using .validate().

like image 642
Falantar014 Avatar asked Apr 16 '13 19:04

Falantar014


1 Answers

$('#myForm').validate().settings.ignore = "newIgnore";

The validate() method returns you a reference to the validator object you created with your original validate() call.

You can then call the property .settings.ignore

like image 113
Dr Blowhard Avatar answered Oct 04 '22 12:10

Dr Blowhard