1

I'm experimenting with HTML built-in validation attributes and the first difficulty I have run into is that the validation attributes work in a form context. I.E. if you want to validate two independent inputs then you should put those inside two different <form> tags.

How do I handle this situation with ASP.NET where the page is formed by a big form containing the whole content?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Marconline
  • 1,108
  • 12
  • 30
  • I also have this problem. I use webforms with angularjs. I have multiple forms on the same page with independent validation at the same time. I haven't solved this, but I see two solutions. 1. Change to ASP.NET MVC or.. 2 Skip html validation attributes and create my own attributes with directives inside angularjs. I'll get back to you when i'm done... – He Nrik Dec 06 '12 at 15:05

2 Answers2

1

I think you have a misunderstanding.

HTML 5 has both form and input validation attributes. The form attributes simply allow you to turn on/off autocomplete and completely turn off validation of all of the input elements.

The input elements are where the real work is performed. Note that you can have autocomplete turned on at the form level, but have it turned off for particular inputs.

BTW, having nested <form> tags is still a no no under HTML5. It's just that various browsers support it in order to continue to be compatible with the vast majority of sites that were coded incorrectly. Actually, this concept, of being as compatible as possible, is the leading reason browsers are so complicated.

More info: http://www.w3schools.com/html5/html5_form_attributes.asp

NotMe
  • 87,343
  • 27
  • 171
  • 245
0

Warning: The following solution isn't beautiful, I know. But it's the only solution I can think of. :/

Create a form-tag side by side with the server-created form-tag. Position the client-side form on top of the page.

Drawback: You cannot use server tags. But hey... who does now a days?! :)

<form runat="server" ...>
    ... Everything ....
</form>
<div class="positionedOnTopOfThePage">
    <form>
        ... Form with HTML5 validation ...
    </form>
    <form>
        ... Form with HTML5 validation ...
    </form>
</div>
He Nrik
  • 1,670
  • 16
  • 17