HTML and CSS Reference
In-Depth Information
It is currently rendered by WebKit-based browsers (having
originally been a proprietary Apple HTML extension) and an alpha
version of Firefox 4 beta.
The required attribute
The new required attribute can be used on <textarea> and
most input fi elds (except when the type attribute is hidden ,
image , or some button types such as submit ). The browser will
not allow the user to submit the form if required fi elds are empty.
We recommend also adding the ARIA attribute aria-required to
such input fi elds for assistive technology (see the discussion of
ARIA in Chapter 2).
The multiple attribute
<input type=file> is not new in HTML5, but when used in
conjunction with the new multiple attribute, the user can now
upload multiple fi les:
<input type=file multiple>
It can also be used with any other input type: for example,
<input type=email multiple> allows the user to enter multiple
email addresses. Currently this is implemented only in WebKit
browsers.
The pattern attribute
Some of the input types mentioned previously—email, number, url,
etc.—are really “baked-in” regular expressions as the browser just
checks if the values entered look like they should.
Suppose you want to match against a different tempate? The
pattern attribute allows you to specify a custom regular expres-
sion that the input must match. So, if the user must always enter
a single digit plus three uppercase alphabetic characters, the
regular expression would be one number [0-9] and three letters
[A-Z]{3}, all in uppercase, and the input would be coded:
<input pattern=”[0-9][A-Z]{3}” name=part
title=”A part number is a digit followed by three
¬ uppercase letters.”>
Yo u c o u l d a l s o a d d a placeholder=”9AAA” or some such as a
short hint.
NOTE If regular expres-
sions scare you but you
want to learn more, or you're
keen to fuel your regular expres-
sion ninja skills, you can take a
gander at Steven Levithan's
blog, which almost exclusively
talks about regular expressions:
http://blog.stevenlevithan.com/
 
Search WWH ::




Custom Search