HTML and CSS Reference
In-Depth Information
Those results are correct, since “bn149” isn't a legal part of a post
code (or certainly not for this contrived example!). Finally, it's worth
noting that the pattern attribute is case sensitive, and since we
don't have any way to switch to case insensitive mode we need
to explicitly match on lowercase and uppercase in this example.
The autocomplete attribute
Most browsers have some kind of autocomplete functionality.
The new autocomplete attribute lets you control how this works.
The default state is for the input to inherit the autocomplete
state of its form owner. Forms have autocomplete on by default.
If the autocomplete attribute of a form element is set to on, the
fi e fi d fi is fi n e fi o r a u t o c o m p fi e t fi o n .
I'll quote the wry humour of the specifi cation's description of the
off state: “The off state indicates either that the control's input
data is particularly sensitive (for example, the activation code for
a nuclear weapon); or that it is a value that will never be reused
(for example, a one-time-key for a bank login) and the user will
therefore have to explicitly enter the data each time.”
The min and max attributes
As we've seen with <input type=number> , these attributes con-
strain the range of values that can be entered in an input; you
can't submit the form with a number smaller than min or larger
than max . But it can also be used with other input types—for
example, <input type=date min=2010-01-01 max=2010-12-31>
will not accept a date that's not in the year 2010. It's trivial to
make the server write HTML that has a min of today, so only
future days are allowed (for a fl ight booking site, for example)
or a max of today (for a fi eld collecting date of birth, for example).
The step attribute
step controls the level of granularity of input. So if you want the
user to enter a percentage between 0 and 100, but only to the
nearest 5, you can specify
<input type=number mix=0 max=100 step=5>
and the spinner control will increment in steps of 5.
 
Search WWH ::




Custom Search