views:

73

answers:

1

Hello, 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:

Enter valid email.Enter valid email.Enter valid email.

Does anyone know what's wrong with it?

Thanks in advance!

A: 

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');
}
Sam
Hello,if I add this code, then my form is disappeared .
novellino
You'll need to customize the selector so it only targets your error elements. Add a sample URL to your question and i'll do it for you.
Sam