我是jQuery验证器的新手。
我正在制作WordPress网站,我正在使用http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/插件dor密码验证。
jQuery验证器无法正常工作且未显示任何错误。
我一直在努力解决这个问题。
$(document).ready(function () {
$("#upme-registration-form").validate({
rules: {
user_login: {
required: true
},
user_email: {
required: true
},
user_pass: {
password: "#user_pass"
},
user_pass_confirm: {
required: true,
equalTo: "#user_pass_confirm"
}
},
messages: {
user_login: {
required: "Enter a username",
minlength: jQuery.format("Enter at least {0} characters")
},
user_email: {
required: "Enter a username",
minlength: jQuery.format("Enter at least {0} characters")
},
user_pass_confirm: {
required: "Repeat your password",
minlength: jQuery.format("Enter at least {0} characters"),
equalTo: "Enter the same password as above"
}
},
// the errorPlacement has to take the table layout into account
errorPlacement: function (error, element) {
error.prependTo(element.parent().next());
},
// specifying a submitHandler prevents the default submit, good for the demo
submitHandler: function () {
alert("submitted!");
},
// set this class to error-labels to indicate valid fields
success: function (label) {
// set as text for IE
label.html(" HELLo").addClass("checked");
}
});
});
我在submitHandler and .validate() issue的帮助下完成了上述代码,但无法正常工作
谢谢
请帮助
答案 0 :(得分:2)
有多个问题
error.appendTo(element.parent());
。演示:Fiddle