Reputation: 1658
Can anyone solve this fiddle. it has two fields password and confirm password. Validation needs to be done such that both password entered should be the same.
$(document).ready(function ()
{
$('#EditForm').validate({
rules: {
password: {
required: true
},
cpassword: {
required: true,
equalTo: "#password"
}
}
});
});
http://jsfiddle.net/kalai789/aCZgK/2/
Thanks in advance
Upvotes: 1
Views: 533
Reputation: 14285
Found similar question
jQuery('.validatedForm').validate({
rules : {
password : {
minlength : 5
},
password_confirm : {
minlength : 5,
equalTo : "#password"
}
}
});
Upvotes: 1
Reputation: 337570
Firstly the external version of jQuery you had loaded was very old (1.5.2) it appears incompatible with the current version of validate, I updated the fiddle to use 1.6.4 as that was the lowest available on jsFiddle. Secondly, the rules
and other settings for the validate plugin are keyed on the name
attribute of the element, not the id
, so they need to be added:
<input type="password" name="password" id="password"/>
<input type="password" name="cpassword" value="" id="cpassword"/>
Upvotes: 3
Reputation: 1170
use keyup
method
check the info source https://stackoverflow.com/a/9717796/1768043
Upvotes: 2