46 Chapter 3—Intelligent Forms
ment with the ID minMaxDate jumps forward seven days each time. Opera only
displays those days in the calendar as active that correspond to the week cycle.
For setting this element, Google Chrome offers the same navigation as with the
input type number: two arrow keys that set the date forward or backward seven
days. In the third input element in this example, the step size is set to 3600; this
causes the time to be set one hour forward or one hour backward. Although the
specification states that the input elements for time usually work in minutes,
both Opera and Google Chrome interpret this data as seconds.
We are all familiar with multiple selection from copying files; now this option ex-
ists for browsers as well. If you wanted to load several files on a website at once,
you previously had to provide an input field for each file. The multiple attribute
allows for the marking of several files in the file dialog. The multiple option was
always intended for the select element; using it for input fields of the type email
is new. But as yet (at the time of this writing), none of the commonly used desk-
top browsers can implement this function for email types.
Modern browsers have a function that allows them to save form data to help the
user fill in forms when the form is revisited. This prefilling can be very useful but
would be undesirable for security-sensitive input fields (the specification men-
tions the activation codes for nuclear weapons as an example). The autocomplete
attribute was introduced to allow web developers to govern this behavior. If an
element has the attribute autocomplete="off" assigned to it, that means the in-
formation to be entered is confidential and should not be saved in the browser.
If the form element does not state if autocomplete should be switched on or off,
the default setting is to display suggestions. The autocomplete attribute can also
be applied to the whole form by assigning it to the form element.
The new pattern attribute allows for very flexible input verification. You can
specify a regular expression against which the form field will be checked for a
match. Regular expressions are very powerful but unfortunately not a very easy
method of parsing strings. Imagine you are looking for a character string start-
ing with an uppercase character followed by any number of lowercase letters or
numbers and ending in .txt. Finding it is no problem at all with a regexp (short
for regular expression):
[A-Z]{1}[a-z,0-9]+\.txt
An introduction to regular expressions would be far beyond the scope of this
chapter, so let’s assume for now that you have basic knowledge of regular
expressions when you read the following section. If you are looking for a
brief online introduction to regular expressions, Wikipedia is a good starting
point: Browse to http://en.wikipedia.org/wiki/Regular_expression. The website
http://www.regexe.com gives you the chance to try regular expressions online.