我进行了很多搜索,但仍然没有弄清楚...如何将各种错误消息传递给单个框(div),而不是在相关字段附近突出显示它们。比方说,我有 4 个必填字段并为它们提供自定义消息:
<script>
// validation
(function($,W,D)
{
var JQUERY4U = {};
JQUERY4U.UTIL =
{
setupFormValidation: function()
{
//form validation rules
$("#register-form").validate({
validClass: "valid",
errorContainer: $("#error-note"),
errorLabelContainer: $([]),
rules: {
name: "required",
email: {
required: true,
email: true
},
birthdate: "required",
eua: "required"
},
messages: {
name: "Name is required",
email: "Please, enter your email",
birthdate: "We need to know your date of birth",
eua: "Please check the checkbox..."
},
submitHandler: function(form) {
form.submit();
}
});
}
}
//when the dom has loaded setup form validation rules
$(D).ready(function($) {
JQUERY4U.UTIL.setupFormValidation();
});
})(jQuery, window, document);
</script>
#error-note
是我需要获取所有/任何错误消息输出(打印)的所有字段之前的 div。但是现在错误消息在相关字段中“内置”(我不需要)。有没有办法实现它?
http://bassistance.de/jquery-plugins/jquery-plugin-validation/