I’m using jQuery Validation to validate a form, and what I would like to do is this… I want it set so if a checkbox is checked than a editbox is validated differently, for example.
This is how it should be validate if the checkbox is not checked:
weight: { required: true, max: 50 }
This is how it should be validated if it is checked.
weight: { required: true, max: 100 }
Any ideas?
You’d use the Validate plugin’s built-in
rules('add')method to dynamically change the rule whenever the checkbox is clicked.jQuery:
HTML:
Working Demo: http://jsfiddle.net/3hGxS/