Introduction to HTML5 input types
With the advent of HTML5, the web form feature has undergone a sea change. Many of the existing and previously much-used elements have been upgraded to have more muscle and lend more control to the designer. HTML5 form features have the potential of reducing the usage of JavaScript for form related functionality like validation, by a big margin. But alas, support for many of these new features have limited browser support currently. There are workarounds nevertheless. The best thing about most of these features
HTML5 defines over a dozen input types for the element that can enhance forms by offering more input control and validation logic that is native to the browser. Here is a list of the new set of input types:
1.
for search boxes
2.
for spinboxes
3.
for sliders
4.
for color pickers
5.
for telephone numbers
6.
for web addresses
7.
for email addresses
8.
for calendar date pickers
9.
for months
10.
for weeks
11.
for timestamps
12.
for precise, absolute date+time stamps
13.
for local dates and times
Additional features
Placeholder text
Placeholder text in input fields is displayed inside the input field as long as the field is empty and not focused. As soon as you click on (or tab to) the input field, the placeholder text disappears.
<input name="searchbox" placeholder="Enter keywords">
<input type="submit" value="Search">
</form>
Autofocus fields
Used to focus on a field automatically.
<input name="searchbox" autofocus>
<input type="submit" value="Search">
</form>
Good thing about most of these features is that browsers that do not support them simply ignores them and treats the associated input field as a regular one.
Latest posts by Smarajit Dasgupta
- Playing with HTML5 - July 29th, 2011
- CSS Tutorial - June 7th, 2011
- 5 Tips for optimizing and cleaning up CSS - April 8th, 2011
- Text level Semantics in HTML5 - March 17th, 2011
- Audio in HTML5 - March 4th, 2011
