[jQuery] [validate] removing or changing rules after validate() method
So I have a field on the page that may or may not be required, depending on
what the user wants to do. Once I need the field to be required, I aplly
validate() on the form and its done. But, once I want to make the field
not-required again, I run into problems.
Here's some example code with markup and failed attempts:
$('#add').click(function(){
$("#form1").validate({
rules: {
textfield: {
required: "required",
min: 1
}
}
});
// Validation is(should be) added
});
$('#remove').click(function(){
$("#form1").unbind('submit');
// The line above removes validation forever and ever, even after we click
#add
$("#form1").validate({
ignore: ".ignore"
// Does not work either
});
});
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" class="ignore" />
<input type="submit" name="button" id="button" value="Submit" />
<input type="button" name="add" id="add" value="Add Validation" />
<input type="button" name="remove" id="remove" value="Remove Validation"
/>
</form>
--
View this message in context: http://www.nabble.com/-validate--removing-or-changing-rules-after-validate%28%29-method-tp16470912s27240p16470912.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.