I'm trying to use 'errorPlacement' from jQuery Validation DOCS, like that:
$("#myform").validate({
errorPlacement: function(error, element) {
error.insertAfter(element);
}
});
So far so good, but what I really want is to insert a <br /> tag between the input and the error label in each case:
<input>
**<br />**
<label class="error">
I have tried with:
error.insertAfter(element.append($('<br />'));
...but no luck. Is there a simple way of doing it? Any help is much appreciated.
You wouldn't need to do that.
Just use the
errorElementoption to change the default error element fromlabel(inline) todiv(block), so that it automatically wraps to the next line.Otherwise, your code...
)$()Would be...
However, that still does not work as intended because
append()is trying to put the content inside ofelement.This way works as you requested...
DEMO: http://jsfiddle.net/1pfvug7r/