jQuery Validation Plugin 1.11.1 插件自定义错误信息提示位置
梁丘宏硕
2023-12-01
return $("#fileForm").validate({
errorPlacement : function(error, element) {//自定义错误提示信息的位置代码
var classname = element[0].className;
if(classname=="input_text_short2 error"){
error.insertAfter($(".map_icon"));
}else{
error.insertAfter(element);
}
},
rules: {
'trader.vcCompanyname':'required',
'trader.vcCompanyaddress':'required',
'trader.vcCompanycontact':'required',
'trader.ntCompanymobilephone':{
required:true,
digits:true,
maxlength:11
},
'trader.vcQqnumber':{
required:true,
maxlength:50
},
'trader.vcCompanydesc':{
maxlength:150
}
},
messages:{
'trader.vcCompanyname':'<span style="color:red">请输入公司名称</span>',
'trader.vcCompanyaddress':'<span style="color:red">请输入公司地址</span>',
'trader.vcCompanycontact':'<span style="color:red">请输入联系人</span>',
'trader.ntCompanymobilephone':{
required:'<span style="color:red">联系人手机号</span>',
digits:'<span style="color:red">请输入数字</span>',
maxlength:'<span style="color:red">电话号码不能大于11位</span>'
},
'trader.vcQqnumber':{
required:'<span style="color:red">请输入qq号</span>',
maxlength:'<span style="color:red">qq号不能大于50位</span>'
},
'trader.vcCompanydesc':{
maxlength:'<span style="color:red">描述不能大于150位</span>'
}
}
}).form();