jQuery Validation - greedy on your forms?

Dec 28, 2010 javascript jquery
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

I was creating a page with two forms on it. I ran into an issue where I would fill out one form, and it would fail validation. Then, I tried to do the other form with passing fields, and it would keep invalidating the previous form on the same page.

I had been doing this:

$('form').validate();

Instead, I found that I needed to loop through each form on the page and validate each single one in their own context. I replaced it with this code:

$('form').each(function() {
   $(this).validate();
});
Go to All Posts