You have probably seen forms
on the web that give users
messages if the form control has
not been ﬁlled in correctly; this is
known as form validation.
Traditionally, form validation
has been performed using
scope of this book). But HTML5
is introducing validation and
leaving the work to the browser.
Validation helps ensure the
user enters information in a
form that the server will be able
to understand when the form
is submitted. Validating the
contents of the form before it is
sent to the server the helps:
Reduce the amount of work
the server has to do
Enables users to see if there
are problems with the form
faster than if validation were
performed on the server.
<input type="text" name="username"
required="required" /></title><br />
<input type="password" name="password"
<input type="submit" value="Submit" />
html5: Form VAlIDAtIon
At the time of writing, only
Chrome and Opera supported
HTML5 validation, although other
browsers are expected to follow.
In order to support older browsers
(that do not understand HTML5),
web page authors are likely to
An example of HTML5 form
validation is the
attribute, which can be used on
any form element that the user
is expected to ﬁll in. This HTML5
attribute does not need a value,
but in HTML 4 all attributes must
have a value. So, some people give
this attribute a value of