Got some hidden fields in a form which needs validation(at some later point say, when made visible)? Lets learn how to remove or add validation rules dynamically using jQuery Validate plugin.
We can use
rules() method of
jQuery-validate plugin to add and remove rules.
Here is how you can remove rules from any element
remove is a string, specified for removing the rules and
rules are the space separated names of rules. This argument is optional, if left unspecified, it removes all the static rules.
Adding rules to the element is also quite simple
add is a string, specified for adding the rules and
rules are the rules to add. These rules are specified in the same format as the rules-option of the validate-method.
Working Example: https://jsfiddle.net/lavika/vtme816s/