Using errorPlacement for control will allow you to place an error message in a specific place.
$("#myform").validate({ errorPlacement: function(error, element) { error.appendTo(element.parent("td").next("td") ); } });
Here are some examples of errorPlacement with error options
- error.appendTo (element.parent ("DIV") next ("DIV").);
- error.appendTo ($ ('# identifier'));
- error.insertAfter (element);
- error.insertBefore (element);
For custom error messages and creating controls
errorPlacement: function(error, element) { var elementForm = "", containerError = ""; offset = element.offset(); elementForm = element.attr("name"); containerError = "#" + elementForm + "error"; error.prependTo(containerError); error.addClass('message'); }
source share