Reputation: 6086
I have a custom validation function to verify that two password fields match using jQuery-Validation-Engine:
<input type="password" class="validate[required,funcCall[checkPassordMatch],maxSize[25]]"...
But if the field is not populated, and the form is submitted, I get the following exception:
Uncaught TypeError: Cannot read property 'checkPassordMatch' of undefined
Is there any way I can only run this validation only if the input is populated, or if "required" passes first?
For reference, my function is as follows:
// Validate the passwords match
function checkPassordMatch(field, rules, i, options){
console.log(field + ' : ' + rules + ' : ' + i + ' : ' + options )
if (field.val() != jQuery("#inputPassword").val()) {
return options.allrules.passwordMatch.alertText;
}
}
Appreciate any thoughts.
Upvotes: 2
Views: 3145
Reputation: 6086
This custom function is not needed. I can use:
validate[required,equals[password]]
Upvotes: 0