Using jquery validate plugin I'm using the rule equalTo to validate a field as follows:
$('#booking').validate({
ignoreTitle: true,
rules: {
payments: {
equalTo: {
param: "#sales",
depends: function(element) { return $("#status").val() == 'invoiced'; }
}
},
}
});
I can get this to work but now I'd only like this rule to apply only if a select option is a particular value. I'm lost on this and not sure how to make the equalTo rule optional dependant on another field value
I saw depends rule but cant find any documentation on this
Can anyone give me some pointers please?
I;ve created a jsfiddle to help:
http://jsfiddle.net/longestdrive/SneAF/2/
Thanks
Updated: I've tried the depends but not working as expected:
Also found some similar/duplicate questions: jQuery Validation - require field only if another field is filled and jQuery validation depends