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.

Download from Wow! eBook <br />

172<br />

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

Table 7-2. New <strong>HTML</strong>5 Form elements appearing in browsers<br />

Type Purpose<br />

tel Telephone number<br />

email Email address text field<br />

url Web location URL<br />

search Term to supply to a search engine. For example, the search bar atop a browser.<br />

range Numeric selector within a range of values, typically visualized as a slider<br />

What do these new input types provide? In terms of programmatic APIs… not a lot. In fact, in the<br />

case of the types for tel, email, url, and search, there are no attributes distinguishing them from the<br />

simplest input type of text.<br />

So, what do you get exactly by specifying that an input is of a specialized type? You get specialized<br />

input controls. (Restrictions may apply. Offer void in many desktop browsers.)<br />

Let’s illustrate with an example. By specifying that an input is of type email:<br />

<br />

rather than using the conventional standard which states that a field is merely of type text:<br />

<br />

you provide a hint to the browser to present a different user interface or input where applicable. You also<br />

provide the browser the ability to further validate the field before submission, but we’ll cover that topic<br />

later in this chapter.<br />

Mobile device browsers have been some of the quickest to take up support for these new form<br />

controls types, and they do so by displaying a different input interface based on the type declared. In the<br />

Apple iPhone, the standard onscreen keyboard display for an input with type text appears as it does in<br />

Figure 7-1.

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

Saved successfully!

Ooh no, something went wrong!