0
我正在登錄頁面上,我希望我的輸入標記內的錯誤文本框內的錯誤消息
現在我在登錄面板的頂部出現錯誤。
這是代碼。
$(document).ready(function() {
$("#form1").validate({
debug: false,
errorClass: "error error_red",
rules: {
username: {
required: true,
email: true
},
password: {
required: true,
minlength: 5
}
},
messages: {
username: "Please enter a valid email address",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
}
},
invalidHandler: function (form, validator) {
// This handler will show only one error at time - the first in this instance //
var errors = validator.numberOfInvalids();
//alert("error" + errors);
if (errors) {
$("#errbox").html(validator.errorList[0].message);
$("#errbox").show();
validator.errorList[0].element.focus();
} else {
$("#errbox").hide();
}
},
errorPlacement: function (error, element) {
// Override error placement to not show error messages beside elements //
},
});
});
這裏是Fiddle Link
問候
馬哈德