您好我正在使用jquery validate插件。我使用equalTo方法检查两个密码字段。
我的密码字段
<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>
我的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",
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"
}
}
});
除密码和cpassword字段的equalTo方法外,其他一切正常。 minlength工作但不等于。我在两个字段中输入相同的值但是它给了我无效的equalTo
的错误答案 0 :(得分:0)
还有另一个带有id密码的字段。这造成了问题。 感谢