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?

1
  • 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... Commented Dec 6, 2012 at 15:05

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

"Having multiple <form> tags is still a no no under HTML5"? Aren't you talking about multiple NESTED form-tags?
@HeNrik: Yes, that would have been a better way to state it.
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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.