Use the errorPlacement method in .validate() to contain the error placement logic. 2 arguements are passed to errorPlacement:
- error: the error text to be inserted into the DOM.
- element: the element being validated.
You can use the error message returned by the validator to decide where it should be positioned. EG:
$("form").validate({
ignore: '',
errorPlacement: function(error, element){
if(error.text() == "This field is required"){
$('.requiredContainer').text(error.text());
}
else
{
$('.genericContainer').text(error.text());
}
});
});
If you're using this with multiple forms, I would suggest putting all of your validator settings in setDefaults() and just using validate() to handle rules/messages etc
setDefaults docs