views:

63

answers:

1

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?

+1  A: 

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?

Rob Fonseca-Ensor