Introduction
HTML5 is the new standard for HTML that has 13 new input types for forms. Using these new input types, we can create more interactive and easy-to-use web forms. It also provides better data validation, input control, color picker controls, and many others.
-
The new input types are:
- Time
- Date
- Datetime
- Datetime-local
- Week
- Month
- Color
- Number
- Range
- Search
- Telephone
- URL
Advantage
These new input types are very useful for web designers. These input types reduce our dependency on the client and server-side scripting, now we don't need to validate our common data types like URLs, email, dates, and so on. You know that one of the biggest pains these days while creating a website is to make those websites cross-platform based that includes Desktop, mobile, and tablets, and if you are creating such web forms using HTML4 standards then you encounter many issues. That's the reason HTML5 input types are a real life-saver and makes our work much easier.
Let's see an example of cross-platform. Here, we have two browsers, the first one is desktop-based and the second one is mobile-based. We used the same code compatible with both platforms:

Here, you can see that the Blackberry native keyboard picks the month because it already knows that the input box is a month type.
Note: It is important to know that not all major browsers are able to support all the input types. Perhaps you can start using them and if they are unable to work properly then at least they'll behave as normal text fields.
Now, let's understand all the input types using examples with their outputs.
1. time
The time type control selects a time, without the time zone.
Example:
- <body>
- <form id="form1" runat="server">
- <div>
- <label for="time-input">Please choose Time:</label> <br /> <br />
- <input type="time" id="time-input" /> <br />
- <input type="time" id="time1" /> <br />
- <input type="time" id="time2" /> <br />
- <input type="time" id="time3" /> <br />
- <input type="time" id="time4" /> <br />
- </div>
- </form>
- </body>
Output

2. date
The date type of control is used to enter a date including month and year (without time).
Example:
- <body>
- <form id="form1" runat="server">
- <div>
- <label for="date-input">Please choose a date:</label>
- <input type="date" id="date-input" />
- </div>
- </form>
- </body>
Output

3. datetime
The datetime control enters a date and time (hour, minute, second, and fraction of a second) that is based on the UTC time zone.
Example
- <body>
- <form id="form1" runat="server">
- <div>
- <label for="date-input">Select your Birth Date & Time(with time zone):</label>
- <input type="datetime" id="date-input" />
- </div>
- </form>
- </body>
Output

4. datetime-local
The datetime-local control enters a date and time, without any time zone.
Example
- <body>
- <form id="form1" runat="server">
- <div>
- <label for="dateTimeLocal-input">Select your Birth Date & Time(without time zone):</label> <br />
- <input type="datetime-local" id="dateTimeLocal-input" /> <br />
- <input type="datetime-local" id="Datetime-local1" /> <br />
- <input type="datetime-local" id="Datetime-local2" /> <br />
- </div>
- </form>
- </body>
Output

5. week
The week type control selects a week and year.
Example:
- <body>
- <form id="form1" runat="server">
- <div>
- <label for="week-input">Select week:</label>
- <input type="week" id="week-input" />
- </div>
- </form>
- </body>
Output

6. month
The month type control selects a month and year, without a time zone.









Gyanender SharmaPosted Sep 5, 2013, 11:38 PM
Thanks Ankur, Glad that you liked it
Gyanender SharmaPosted Sep 5, 2013, 11:37 PM
Thanks Gakenh01
Ankur MishraPosted Sep 5, 2013, 5:09 PM
Very helping Gyanender, Representation is very good.
Gakenh01Posted Sep 5, 2013, 7:30 AM
nice article.
Gyanender SharmaPosted Sep 5, 2013, 3:55 AM
Thanks Sanjeeb
Sanjeeb LenkaPosted Sep 5, 2013, 12:43 AM
really awesome article with good information.