开发者

jQuery Validation plugin attaches only to the first form

I have noticed a strange jQuery Validation plugin behaviour, possible a bug (tested with the latest version at http://dev.jquery.com/view/trunk/plugins/validate/开发者_运维知识库jquery.validate.js).

Suppose I have several forms on a page.

This code leads to only first form to be validated:

$(document).ready(function() {
    $("form").validate();
});

But this one attaches data validator to all forms:

$(document).ready(function() {
    $("form").each(function() {
        $(this).validate();
    });
});

Is it by design? Why can't I handle all forms at once?


The api for validate does state that it "Validates the selected form" (not forms), but I agree that that's not very jQueryish. Maybe you should suggest it as an enhancement, I can't imagine that breaking any old code?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜