I am trying to display a validation error message beside the form field reportFileURL. Here is the code which submits the form
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"
});
I am using a alertbox to display that the report file is url. Please suggest me a solution for this.
With errorPlacement
else{
var error = result.errorMessage;
errorPlacement: function(error, element) {
error.insertAfter("#reportFileURL")
}
return false;
}