我正在使用jQuery Validation Plugin在我的页面上并有以下代码 errorPlacement
:
errorPlacement: function(err, el) {
err.insertAfter(el);
}
按预期工作,但对于必填字段,我不希望为必填规则显示默认消息。因此,如果电子邮件有 required
的规则和email
,我只想显示 email
的错误消息。规则,而不是 required
规则。有没有办法只禁用所需的消息?
最佳答案
$('#myForm').validate({
rules: {
myField: {
required: true,
email: true
}
},
messages: {
myField: {
required: "",
email: "my email rule error message"
}
},
// my other options & configuration parameters
});
关于jQuery 验证插件 - 不显示必需的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10091998/