我有 jQuery 验证插件:
//name validation
cnForm.validate({
rules: {
customerName: {
required: true,
minlength: 3
},
date: {
required: true,
dateRegex: /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/,
maxlength: 10
}
},
onkeyup: false,
onclick: false,
onfocusout: false,
messages: {
customerName: {
required: "Unable to proceed, search field is empty"
},
date: {
required: "Unable to proceed, search field is empty"
}
},
errorPlacement: function(error, element) {
var trigger = element.next('.ui-datepicker-trigger');
error.insertAfter(trigger.length > 0 ? trigger : element);
}
});
每当我输入导致错误的数据时,我都会在输入框/按钮之后显示适当的新标签,但该类error
也应用于输入框。有没有办法避免将该类分配给盒子?谢谢。