11

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().

1

1 Answer 1

20
$('#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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, I don't know how I wasn't able to find this myself.
@Falantar014 Probably because it's a needle in a haystack. I've just tried 50 different things that you'd expect to reset or "forget" the old ignore setting (including your extremely reasonable approach put forward in the question) . But nope, only this.
This is what I ended up doing after I found out validate() caches the validator the first time it's created and then ignores any new options passed to it in successive calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.