25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The autocomplete Attribute<br />

CHAPTER 7 ■ USING THE <strong>HTML</strong>5 FORMS API<br />

The autocomplete attribute, introduced in Internet Explorer 5.5, has finally been standardized. Hooray!<br />

(Browsers have been supporting the attribute for nearly as long as its inception, but having a specified<br />

behavior helps everyone.)<br />

The autocomplete attribute tells the browser whether or not the value of this input should be saved<br />

for future. For example:<br />

<br />

The autocomplete attribute should be used to protect sensitive user data from insecure storage in<br />

the local browser files. Table 7-4 shows the different behavior types.<br />

Table 7-4. Autocomplete behavior in input controls<br />

Type Purpose<br />

on The field is not secure, and its value can be saved and restored.<br />

off The field is secure, and its value should not be saved.<br />

unspecified Default to the setting on the containing . If not contained in a form, or no value is<br />

set on the form, then behave as if on.<br />

The autofocus Attribute<br />

The autofocus attribute lets a developer specify that a given form element should take input focus<br />

immediately when the page loads. Only one attribute per page should specify the autofocus attribute.<br />

Behavior is undefined if more than one control is set to autofocus.<br />

■ Note Only one autofocus control per page is difficult to achieve if your content is being rendered into a portal or<br />

shared content page. Do not rely on autofocus if you are not in complete control of the page.<br />

To set the focus automatically to a control such as a search text field, simply set the autofocus<br />

attribute on that element alone:<br />

<br />

Like other boolean attributes, no value needs to be specified for the true case.<br />

177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!