El Noguer

Joaquim Perez i Noguer

Html5: novetats en els formularis (II)

Filed under: Web — Joaquim Perez Noguer at 10:22 am on Dimecres, juny 29, 2011

Més informació (en anglès) sobre els nous formularis HTML 5.

Ja fa un temps que vaig parlar sobre de com canviarien els programes d’Internet amb el nou HTML5, sobre tot amb els canvis amb els formularis.

Dive Into HTML5 és un bon bloc per aprendre a programar amb  HTML5.

 

INPUT REQUIRED

Test <input required> in your own browser. Browsers may alter the default appearance of required fields. For example, this is what a required field looks like in Mozilla Firefox 4.0:

default appearance of required fields in Firefox

 

VALIDATORS

HTML5 also offers validation of web addresses entered into <input type="url"> fields, and numbers in <input type="number"> fields. The validation of numbers even takes into account the min and max attributes, so browsers will not let you submit the form if you enter a number that is too large.

error message on invalid type=number field

 

DATE FIELDS

This is how Opera renders <input type="date">:

Opera's type=date picker

PLACEHOLDER

You’ve probably seen placeholder text before. For example, Mozilla Firefox includes placeholder text in the location bar that reads “Search Bookmarks and History”:

location bar with placeholder text

MOBILE BROWSER

For example, email addresses are text, right? Sure, but they’re a special kind of text. For example, virtually all email addresses contain the @ sign and at least one period (.), but they’re unlikely to contain any spaces. So when you use an iPhone and focus an <input type="email"> element, you get an on-screen keyboard that contains a smaller-than-usual space bar, plus dedicated keys for the @ and . characters.

iPhone rendering input type=email field
Test type="email" for yourself.

 

SPINBOXES

Spinboxes are not the only way to represent numeric input. You’ve probably also seen “slider” controls that look like this:

Chrome rendering of input type=range field as slider control
Test type="range" for yourself.

You can now have slider controls in your web forms, too. The markup looks eerily similar to spinbox controls:

↶ The spitting image

<input type="range"
       min="0"
       max="10"
       step="2"
       value="6">



No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>