HTML and CSS Reference
In-Depth Information
3.3 Utilizing Date and Time Input Fields
Problem
You want to provide a user with a form to specify a date and/or timeāfor example,
when scheduling an appointment.
Solution
HTML5 provides a number of new input types to assist in date and time entry.
This first solution uses the
input
element with the HTML5
type
value of
datetime
to
display both a date-picker widget and a time spinner control in combination, as shown
in
Figure 3-8
:
<form>
<p><label>Appointment Date and Time <input
type="datetime"
name="dateAndTime"></label></p>
<p><button type="submit">Submit</button></p>
</form>
Figure 3-8. The datetime input field renders a date-picker widget and time spinner control in
Opera 11.5