我想在弹出窗口中显示Postcode字段错误消息。其他字段错误消息不需要弹出。我使用下面的代码。如何解决这个问题。
$(document).ready(function() {
$("#conference_form").validate({
rules: {
conpostcode: {
required: true,
minlength: 4,
remote: {
url:"<?php echo base_url() ?>tools/check_postcode/1",
type: "post",
data:
{
postcode: function()
{
return $('#conpostcode').val();
}
},
}
},
name: "required",
address: "required",
date: "required",
description:"required",
},
messages: {
conpostcode: "We don't have service this location, Please call us +44 12345454, for stock sets support.",
name: "Please enter venu name",
address: "Please enter address",
date: "Please enter date",
description: "Please enter description",
}
})
});
如何仅在警报或弹出窗口中显示邮政编码错误消息。请任何帮助。
答案 0 :(得分:4)
使用errorPlacement
选项
errorPlacement(默认值:将错误标签放在无效元素之后) 类型:功能() 自定义创建的错误标签的位置。第一个参数:创建的错误标签为jQuery对象。第二个参数:作为jQuery对象的无效元素。
errorPlacement: function(error,element){
//error.insertAfter(element);
//use error.html() as content in your popup div or simply
alert(error.html());
}