Heres the code that im working with:
$('#button').click( function (e) {
var rules = rules_data; //object that holds all rules for form validation
if (a == b) { //some random criteria
delete object.rule5; //deletes specific rule (in this case 'rule5') out of object if criteria is met, otherwise the rules object is unchanged
}
var validate_form = $('#form').validate(rules);
if (validate_form === false) {
e.preventDefault();
}
});
My problem with this code - even tho the rules object changes like it supposed to on each button click (if criteria is met), the validation only takes rules of the 1st click and gets stuck with those rules even if rules were changed. I mean, if rules are changed on button click, i want the validation to discard the old rules and apply the new ones, but that is not happening for some reason.
Any suggestions? Maybe im doing something wrong here?