开发者

jQuery Validation Form message position

This is a part of my validate method:

...
 rules: {
           name: {
               required: true
           },
           surname: {
               required: true
           },
           tel: {
               require开发者_StackOverflowd: true,
               digits: true
           }
      },
      errorElement: "div" ,
      errorPlacement: function(error, element) {   
        error.insertAfter(element)     
    }....

The problem is that when validate method has to put the message on the form, it doesn't erase the previous error message if it exists. So I have for example this situation (if the validate method is run 2 times):

NAME:
HTML_TEXT_INPUT
ERROR1
ERROR2

When the second error is in errorPlacement, it doesn't remove the previous ERROR1.

Hoe can I fix this?

Update: In jsFiddle http://jsfiddle.net/michelejs/Ax7Bs/ it works, but at http://mongolera.dyndns.biz/projects/regioni/form2.php i have the same problem!

What could it be?


I'm surprised you got this to run at all, here is one issue with your implementation:

jQuery Validation Form message position

This is actually causing the validation script to not run at all for me on FF5 on the page you linked to.

I'm happy to provide more feedback if you can provide a working example.

EDIT1: I see this is working in Chrome, but you should still either define container or remove that line, you may see the issue disappear.

EDIT2: I see you are using version 1.5.2 of the validation plugin on your page, while the jsfiddle uses version 1.8. Both demos use jQuery 1.6.

There are known issues with jQuery 1.6 and any version of the validation plugin below 1.8, I suggest you upgrade to the latest version, as I don't see any apparent errors in the code you have provided, and as you see it is working fine in the fiddle. Here is the link for the current validation plugin:

  • Stable: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
  • Latest: https://github.com/jzaefferer/jquery-validation
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜