tags:

views:

302

answers:

2

If all asp.net controls are required to be within a form in order to be generated, how does one go about using the jquery validation plugin with multiple forms on the same page?

What I mean by that is, how can I have two forms both containing asp controls that can be validated independently with jquery validation?

+1  A: 

Validate all of them:

$("form").validate();

...or only forms with a certain class:

$("form.validateMe").validate();
Craig Stuntz
The problem Craig is that asp.net only allows you to have one form. All asp rendered controls must be within this form.Having another form means I'll have to use HTML controls not rendered on the server which is a bit convoluted since I have two coding styles.
Sir Psycho
You asked how to use jQuery to validate multiple forms on one page, did you not? That is the question I answered. If you actually intended to ask a different question, well, you'll need to say what it is. I think the best way to work around ASP.NET's limitations is to use MVC.
Craig Stuntz
If you read my question I said asp.net controls. asp.net only allows one form at a time as I've since found out.
Sir Psycho
A: 

The problem here is you want two forms in the first place. ASP.NET, as far as I know, forces you to put all your controls in a single form.

So nevermind the validation at all. The jQuery validation would be easy (See Craig's answer). The two forms in ASP.NET is a different story.

You could probably hack it with iframes or something, but I'd advise against it.

Adam A