I have a custom rule that should check some dependencies by validating the other inputs this one depends on. When I do stuff like that validation for all other inputs seems to be ignored.
This one is my custom validation rule:
jQuery.validator.addMethod("checkDependencies", function (value, element) {
var valid1 = jQuery('form#add-lottery-form').validate().element('#input-1');
var valid2 = jQuery('form#add-lottery-form').validate().element('#input-2');
if (valid1 && valid2) {
return true;
} else {
return false;
}
}, 'dependencie error');
I have created a jsfiddle to show my problem:
http://jsfiddle.net/AQcrW/
steps to reproduce:
- type something in input4 (this input is the one with custom rule "checkDependencies") [line 1 in JavaScript-part]
- errors on input1 and input2 are shown due to calls in JS line 2 and line 3
- insert correct values to input1 and input2
- click submit
- !!recognize that input3 was not validated!!
rerun the fiddle
- click submit
- all fields are validated as expected
Is this my fault or is it a bug in jQuery validation?