My form has several rather complex validation rules and it became necessary for me to temporarily disable a given rule only to enable it later. It seemed pointless having to remove it and then add it again later so I needed a facility to disable and enable validation rules.
My form has several rather complex validation rules and it became necessary for me
Share
Starting with jquery.validate.js from version 1.8.1 I added in 2 case statments to the “rules” function so that the command switch statement reads as follows.
Then to implement this, in the “check” function we add a conditional to check the state of this disabled parameter we have set. Notably, if the rule has never been disabled/enabled then the value will be undefined, we assume here that if its undefined we’re happy with the rule. The loop statement for this function now starts with:
Use this just as you would the “add” and “remove” facilty, e.g.
I hope this helps someone, I’ve been bashing my head against the wall trying to get to here.