我正在尝试在表单字段reportFileURL旁边显示验证错误消息。这是提交表单的代码
var uploadForm = $("#uploadMVRContentForm");
uploadForm.validate({
submitHandler: function(form) {
uploadForm.ajaxSubmit({
dataType:'json',
success:function(result){
if(result.success === true ){
mvrContentFormDiv.hide();
document.getElementById('uploadMVRContentForm').reset();
displayMVRContent();
}
else{
alert(result.errorMessage);
return false;
}
}
});
},rules: {
"mediaValueReport.mainTitle": "required",
"mediaValueReport.reportFileURL": "required",
"mediaValueReport.indexPageImageURL":"required",
"mediaValueReport.landingPageImageURL":"required",
"mediaValueReport.seoURL":"required",
"reportDate":"required"
},
errorElement: "span"
});
我正在使用警告框来显示报告文件是网址。请为我建议一个解决方案。
使用errorPlacement
else{
var error = result.errorMessage;
errorPlacement: function(error, element) {
error.insertAfter("#reportFileURL")
}
return false;
}
答案 0 :(得分:1)