HTML and CSS Reference
In-Depth Information
Figure 5-28 shows how validation errors are displayed for server-side errors.
Figure 5-28. Server-side validations from data annotations and MVC
The error message shown in Figure 5-28 comes from the User data model class. Because this
validation happens on the server, the Password field loses its value.
Most ASP.NET applications are data driven and involve forms in some way or another. HTML5 provides an
array of features that enhance forms, the most noticeable being the new input types. Input types such as
email , url , tel , and date allow you to enforce validations on the data being entered without needing any
client-side script. Additionally, features such as required fields, pattern matching, autofocus, placeholders,
and spell-check help you to develop rich forms with minimal markup and script.
Of course, you may still need to rely on server-side validation or custom validation as a fallback
mechanism to deal with browsers that don't support HTML5. HTML5 also lets you customize validation
messages and the way those messages are displayed.
HTML5 form features can be used by Web Forms as well as MVC applications. The TextMode property
of the TextBox server control supports various HTML5 input types. MVC applications can use raw <input>
tags or use HTML helpers to render HTML5 input types.
Search WWH ::

Custom Search