jquery validate problem
hi i am using jquery validate plugin. I am using equalTo method for checking both password fields.
my password fields
<p><label for="password">Password:<span class="important">*</span></label><input id="password" type="text" name="password" class="required" /></p>
<p><label for="cpassword">Confirm Password:<span class="important">*</span></label><input id="cpassword" type="text" name="cpassword" class="required" /></p>
my jquery
$("#registeruser").validate({
rules: {
username: {
required: true,
minlength: 3,
remote: {
url: "checkuser.php",
type: "post",
data: {
username: function() {
return $("#username").val();
}
}
}
},
password: {
required: true,
minlength: 6
},
cpassword: {
required: true,
minlength: 6,
equalTo: "#password"
},
email: {
required: true,
email: true,
remote: {
url: "checkuser.php",
开发者_JAVA技巧 type: "post",
data: {
email: function() {
return $("#email").val();
}
}
}
}
},
messages: {
username: {
required: "Please enter a username",
minlength: "Your username must consist of at least 3 characters",
remote: "This username is already registered"
},
password: {
required: "Please provide a password",
minlength: "Your password must be at least 6 characters long"
},
cpassword: {
required: "Please provide a password",
minlength: "Your password must be at least 6 characters long",
equalTo: "Please enter the same password as above"
},
email: {
email: "Please enter a valid email address",
remote: "This email is already registered"
}
}
});
everything else working fine except the equalTo method for the password and cpassword fields. minlength is working but not equalTo. I am entering same values in both fields but it is giving me error for invalid equalTo
there was another field with id password. That was creating problem. Thanks
精彩评论