Problem with errorPlacement in validator plugin jQuery
I am using the validator plugin of jQuery. By default the error label is added below my form. I want to add it above my form. So what I am doing is adding the code below in the validate():
errorPlacement: function (error, element) {
error.insertBefore('form#emailForm');
}
The problem is that the error label now is added a lot of times above the form, in every click. So I have something like this:
E开发者_StackOverflownter valid email.Enter valid email.Enter valid email.
Does anyone know what's wrong with it?
Thanks in advance!
If they're getting added lots of times all you have to do is remove them before they're added.
errorPlacement: function (error, element) {
$('.error').remove();
error.insertBefore('#emailForm');
}
精彩评论