in javasc...">

Validator validation jquery validate () and selector

I have two forms per page

<form id="form1">
</form>
<form id="form2">
</form>

in javascript
$('form').validate();

Only the validator for form1 not form2 applies above. I thought the jquery selector applies to all matched elements.

I had to call confirmation in a separate form in order to apply

Is there something wrong with what I am doing / expecting? not $ ('form'). should validate () apply to all forms on the page?

+3
source share
2 answers

While the jQuery function captures each corresponding element for the selector, for the plugin to use these elements. It looks like the validate plugin that you are using (cannot confirm that it is this one ) only grabs the first selector element to act,

validate , .

$('form').each(function(){
    $(this).validate();
});
+10

:

$('form').each(function(){
    $(this).validate();
});
+4

All Articles