Logo
  Sunday, May 20, 2012
Sign-In  |  Sign-Up  |  Contact Us  | Bookmark |  RSS Feed

HTML5 Tutorial FeedBurner

HTML5 Date and Time Picker Control  
HTML5 forms use date and time controls regularly. HTML5 date and time controls are used by booking sites, scheduling events sites or flight arrivals scan sites.

HTML5 Date and time control is useful in several ways. First, users can see day of the week while picking a date. Second, it prevents users from making a mistake in selecting proper date. For instance, some years have February 28th and not February 29th and some years have February 29th as valid dates.

It is common to use JavaScript for date and time control, also known as date picker control. There are Ajax based frameworks that render date picker and bind it to the form field. However, there is no need to use any of that with HTML5.

HTML5 has several controls that deal with date and time. They are different in appearances and behaviors. For example there are two different HTML5 controls for dates and time.

HTML5 Date control: <input type="date" />
HTML5 Time control: <input type="time" />

In addition, HTML5 date picker control can be rendered as calendar pop-up control as shown on the picture below.


Pic. 1: HTML5 Calendar Control

There are other HTML5 date and time controls that allow flexibility for your online form when it comes to choosing dates.

HTML5 month control: <input type="month" />
HTML5 week control: <input type="week" />

Sample code and HTML5 boilerplate file for four different HTML date and time control presented below:

<!DOCTYPE html>

<html>

  <head>

    <title>HTML5 Date and Time Control</title>

  </head>

 <body>

 

<form id="myForm">

<input type="date" />

<p>

<input type="time" />

<p>

<input type="datetime" />

<p>

<input type="month" />

<p>

<input type="week" />

</form>

</body>

</html>

Download HTML5 Date and Time Code: Download HTML5 Date and Time Code

Print HTML5 Date and Time Picker Control Bookmark HTML5 Date and Time Picker Control

Related Articles  
Adding HTML5 Spellcheck to the HTML5 Form
The W3C's HTML5 specification added HTML5 spellcheck attribute to input and textarea elements of the HTML5 web page.
HTML5 Email Input Type Tag
HTML5 introduced several new input types. On the important types is email input type. HTML5 Email Input type creates a ...
HTML5 Custom Tags
The HTML5 allows you to customize an input tag. The HTML input tag can be modified to allow custom validation in a more ...
Adding Placeholder Text in HTML5 Input Fields
HTML5 has new way of adding this text via input attribute called "placeholder". You can assign text to this placeholder ...
HTML5 Form Input Types
HTML5 forms have new set of input types in addition to well known and widely used input types such as text, checkbox, ...
HTML5 Drag and Drop Key Concepts
HTML5 Drag and Drop is modeled after desktop based application. As a result, HTML5 drag and drop is easy to implement ...
More