I'm trying to use 'errorPlacement' from jQuery Validation DOCS:
$("#myform").validate({
errorPlacement: function(error, element) {
error.appendTo( element.parent("td").next("td") );
},
debug:true
})
I want to place error before not valid input, but this does not work:
$("#myform").validate({
errorPlacement: function(error, element) {
error.appendTo( element.parent("form").prev("input") );
},
debug:true
})
Any help much appreciated!
Since you want to insert the error message before the invalid element, use insertBefore():
errorPlacement: function(error, element) {
error.insertBefore(element);
}