I need to compare two input text fields of a form using a custom rule for jQuery Validate.
I tried the following code
//Our validation script will go here.
$(document).ready(function(){
//custom validation rule - text only
$.validator.addMethod("NotEqualTo",
function(value, element) {
return ???;
}, "Two Properties are matching"
);
$("#frmUpdatePassword").validate({
onfocusout: true,
rules: {
NewPassword: {
NotEqualTo: '#OldPassword' }
},
messages: {
NewPassword: {
NotEqualTo: "Two Properties are having same values"
}
}
});
});
The HTML TextBox
is
<input type="password" id="OldPassword" name="OldPassword" />
<input type="password" id="NewPassword" name="NewPassword" />
Kindly assist me how to compare for not equal of two properties in a generic manner not only for comparing these two fields.