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.

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

and its virtual keyboard display, as we will see shortly. More advanced features such as validation are<br />

just being introduced. Table 7-1 summarizes the current state of <strong>HTML</strong>5 Forms support today.<br />

Table 7-1. Browser support for <strong>HTML</strong>5 Forms<br />

Browser Details<br />

Chrome 5.0.x supports input types email, number, tel, url, search, and range. Most<br />

validation.<br />

Firefox Not supported in 3.6. Initial support coming in 4.0.Unsupported input types such<br />

as url, email, and range will fall back to a text field.<br />

Internet Explorer Not supported, but new types will fall back to a text field rendering.<br />

Opera Strong support for initial specifications in current versions, including validation.<br />

Safari 4.0.x supports input types email, number, tel, url, search, and range. Most<br />

validation. Some types supported better in mobile Safari.<br />

Checking for browser support is less useful in the context of the new <strong>HTML</strong>5 Forms, as they have<br />

been designed to degrade gracefully in older browsers. Largely, this means that it is safe for you to use<br />

the new elements today, because older browsers will fall back to simple text field displays for any input<br />

types that they do not understand. However, as we’ll see later in this chapter, this raises the importance<br />

of multi-tier form validation, as it is not sufficient to rely on the presence of browser validators to enforce<br />

the data types for your form controls, even if you assume full modern-browser support.<br />

Now that we have surveyed the browser landscape, let’s take a look at the new form controls added<br />

in the <strong>HTML</strong>5 specification.<br />

An Input Catalog<br />

One of the best places to get a catalog of all the new and changed elements in <strong>HTML</strong>5 is the markup list<br />

maintained at the W3C site itself. The W3C keeps a catalog page file at http://dev.w3.org/html5/markup/<br />

This page denotes all the current and future elements in an <strong>HTML</strong> page. New and changed elements<br />

are noted in the catalog list. However, “new” in this list only means that the element has been added<br />

since the <strong>HTML</strong>4 specification—not that the element is implemented in browsers or in a final<br />

specification yet. With that warning in place, let’s take a look at the new form elements arriving with<br />

<strong>HTML</strong>5, starting with the ones that are being implemented today. Table 7-2 lists the new type attributes.<br />

For example, many <strong>HTML</strong> developers will be intimately familiar with and . The new input types follow a similar model to the existing ones.<br />

171

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

Saved successfully!

Ooh no, something went wrong!