• Category Category: HTML
  • Comment Comments: 16
  • View View: 2405

HTML5 includes the several new ‘input types’, these input types are used for better control and validation.

This article covers the following input type one by one:

  • email
  • number
  • color
  • datedime
  • datetime-local
  • date
  • month
  • week
  • range
  • search
  • url
  • tel

New Input Types

The good thing about new input types in html5, if browser not supports  any type, than it displays in default input type of text with no errors or exceptions.

Email:

This field is used to enter the email address. The value of the email field is automatically validated when the form is submitted.

<span style="color: #e71728;"><strong>&lt;input type="email" value="no-reply@email.com" /&gt;</strong></span>

Number:

This field is used to enter the number (digit), also supports the floating number. You can set the minimum and maximum values of the number. Also you can specify the number interval by using the ‘step’ attribute.

<span style="color: #e71728;"><strong>&lt;input type="number" min="1" max="10" step=”2”/&gt;</strong></span>

Color:

The color type is used for input fields that should contain a color. The Opera browser will allow you to select a color from a color picker, Google’s Chrome will only allow hexadecimal color values to be submitted. This input type could be represented by a wheel or swatch picker.

<span style="color: #e71728;"><strong><code>&lt;input</code> <code>type="color"</code> <code>value="#b98b58"&gt;</code></strong></span>

DateTime:

This field is used to select the date and time (UTC time).

<strong><span style="color: #e71728;">&lt;input type="datetime" value="2011-10-23T20:35:34.32"&gt;</span></strong>

datetime-local:

An element to choose both date and time, with local settings support.

<strong><span style="color: #e71728;">&lt;input type="datetime-local" value="10-23-2011T22:41"&gt;</span></strong>

Date:

This field is used to select the date.

<span style="color: #e71728;"><strong>&lt;input type="date" value="2011-11-23"/&gt;</strong></span>

Month:

This input type is used to select the month and year.

<strong><span style="color: #e71728;">&lt;input type="month" value="2011-11"&gt;</span></strong>

Week:

This input type is used to select the week and year.

<strong><span style="color: #e71728;">&lt;input type="week" value="2011-W48"&gt;</span></strong>

Range:

This field is a slider, to set a certain value or position. You can set the minimum and maximum value of the slider. Also you can specify the number interval by using the ‘step’ attribute.

<strong><span style="color: #e71728;">&lt;input type="range" value="15" min="0" max="100"&gt;</span></strong>

Note: If not set, default attribute values are min=”0″, max=”100″, step=”1″.

Search:

The search type is used for search fields, like a site search, or Google search. this field behaves like a regular text field.

<strong><span style="color: #e71728;">&lt;input type="search"/&gt;</span></strong>

Note: In WebKit-based web browsers (Google Chrome, Safari) you can add the non-standard results attribute to get a looking glass icon to click to see the latest searches, and the attribute autosave to keep them across page loads.

<strong><span style="color: #e71728;">&lt;input type="search" results="5" autosave="saved-searches"  placeholder="Search..."<span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">&gt;</span></span></span></strong>

URL:

The url type is used for input fields that should contain a URL address. The value of the url field is automatically validated when the form is submitted.

<strong><span style="color: #e71728;">&lt;input type="url" value="http://www.codeheaven.org"&gt;</span></strong>

Note: requires a protocol like http://, ftp:// etc in the beginning.

Tel:

This input type is used to enter the telephone number.

<strong><span style="color: #e71728;">&lt;input type="tel" value="[Any numeric value]" </span></strong>
<strong><span style="color: #e71728;">pattern= <span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">"^\(?\d{3}\)?[-\s]\d{3}[-\s]\d{4}.*?$" </span></span></strong><strong><span style="color: #e71728;"><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">placeholder="(555) 555-2222"</span>&gt;</span></strong>

Note: Most web browsers seem to let through any value at this time.

Read further HTML5 new Form attributes 

admin Article's Source: http://codeheaven.org/html5-new-input-types.html
Author:

  • authorBy:
  • writerPosted On: October 22, 2011
  • livePublished articles: 36

Comments (16)

  • Cleora Rendel
    Cleora Rendel Say (January 30, 2012 at 11:30 am)

    Hey very nice site!! Man .. Beautiful .. Amazing .. I’ll bookmark your site and take the feeds also…I am happy to find a lot of useful info here in the post, we need develop more techniques in this regard, thanks for sharing.

  • Isagenix 9 day cleanse
    Isagenix 9 day cleanse Say (December 11, 2011 at 6:25 pm)

    Excellent post. I had been checking continuously this web site and Im impressed! Useful information especially the last part :) I attend to such info much. I used to be seeking this certain information for a long period. Thank you so much and all the best !.

  • App For Android
    App For Android Say (December 7, 2011 at 9:04 am)

    I got what you designate, thanks for swing up. Woh I am happy to grow this website finished google. Thanks For Share HTML5 new input types | Coding techniques and tips.

  • Android Apps
    Android Apps Say (December 7, 2011 at 9:02 am)

    I got what you signify, thanks for putting up. Woh I am happy to ascertain this website finished google. Thanks For Share HTML5 new input types | Coding techniques and tips.

  • App For Android
    App For Android Say (November 29, 2011 at 3:39 pm)

    I like Your Article about HTML5 new input types | Coding techniques and tips Perfect just what I was looking for! .

    • Brenley
      Brenley Say (December 7, 2011 at 9:18 am)

      You’re a real deep thinker. Thanks for sahnirg.

  • Riptide GP apk
    Riptide GP apk Say (November 27, 2011 at 7:31 am)

    I got what you think, thanks for putting up. Woh I am gladsome to pronounce this website finished google. Thanks For Share HTML5 new input types | Coding techniques and tips.

  • myp2peu.org
    myp2peu.org Say (November 14, 2011 at 10:42 pm)

    Great artical, had no problems printing this page either.

  • Syed Akhtar
    Syed Akhtar Say (November 2, 2011 at 4:56 am)

    Thanks for writing this. Quite informative artical.

    • admin
      admin Say (November 4, 2011 at 4:20 am)

      thank you very much

  • coal crusher
    coal crusher Say (November 1, 2011 at 4:38 am)

    Your post attracted my attention and I appreciated it very much. You write it clearly and cautiously.

  • Raaghu
    Raaghu Say (October 31, 2011 at 8:20 am)

    Hi, Thanks for great information

    Will all the these works on < IE9 (IE7 & 8), if not what is the alternative. let us know please

    • admin
      admin Say (October 31, 2011 at 6:47 pm)

      you are welcome. here are the list of popular browsers which support new html5 input types.

      Chrome: 5.0.x supports input types email, number, tel, url, search, and range. Most
      validation.

      Firefox: Not supported in 3.6. Initial support coming in 4.0.Unsupported input types such as url, email, and range will fall back to a text field.

      Internet Explorer: Not supported, but new types will fall back to a text field rendering.

      Opera: Strong support for initial specifications in current versions, including validation.

      Safari: 4.0.x supports input types email, number, tel, url, search, and range. Most
      validation. Some types supported better in mobile Safari.

      • Jerry
        Jerry Say (November 28, 2011 at 3:28 am)

        You ralely saved my skin with this information. Thanks!

        • Chuck
          Chuck Say (December 7, 2011 at 2:51 am)

          IMHO you’ve got the right anwser!

        • Bono
          Bono Say (December 9, 2011 at 12:39 am)

          Whoever wrote this, you know how to make a good atrilce.

Post Comment


9 − = four

 
May 2013
M T W T F S S
« Oct    
 12345
6789101112
13141516171819
20212223242526
2728293031  
Technologies