Form in Html5
Form in Html5
FORM
<form>
.
form elements
.
</form>
Tag
<form>
<input>
Description
Defines an HTML form for user input
Defines an input control
<legend>
<select>
<optgroup
>
<option>
<button>
Text Input
<form>
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
CheckBox
<form action="">
<input type="checkbox" name="vehicle"
value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle"
value="Car">I have a car
</form>
FORM in HTML5
FORM in HTML5
HTML5 several new form fields have been added to the
existing form fields in HTML4
form fields are targeted at receiving special type of
data, e.g. email addresses, URL's, dates etc., and come
with built-in browser validation.
Email Field
The email input field can take text input and validate
that the input is a valid email address.
To specify that an input field is an email field using the
type="email" attribute, like this:
<input type="email" name="emailField"/>
URL Field
The URL field can take text input and validate that the
input is a valid URL.
To specify that an input field is a URL field using the
type="url" attribute, like this:
<input type="url" name="urlField"/>
Number Field
The number field can take text input and validate that
the input is a valid number.
The browser may assist the user by showing a numeric
keyboard, e.g. on a mobile phone.
<input type="number" name="numberField"/>
min
max
step
Range Fields
The range fields are used like number fields, but instead
of having an arrow up and down to select the value, you
have a slider.
<input type="range" name="rangeField"/>
Search Fields
The search fields are used for input to website searches.
The search fields can show a history of previous search
terms, to make searching easier.
You specify that an input field is a search field using the
type="search" attribute, like this:
<input type="search" name="searchField"/>
Tel Fields
The tel fields are used for telephone numbers.
Unlike the number field, a tel field can contain spaces in
between the numbers, but still no letters.
You specify that an input field is a tel field using the
type="tel" attribute, like this:
<input type="tel" name="telField"/>
Date Field
The date field can take text input and validate that the
input is a valid date.
You specify that an input field is a date field using the
type="date" attribute, like this:
<input type="date" name="dateField"/>
Time Field
The time field can take text input and validate that the
input is a valid time.
Time fields allow input hours between 0 and 23, and
minutes between 0 and 59.
You specify that an input field is a time field using the
type="time" attribute, like this:
<input type="time" name="timeField"/>
Datetime Field
The datetime field can take text input and validate that
the input is a valid date and time.
You specify that an input field is a date field using the
type="datetime" attribute, like this:
<input type="datetime" name="datetimeField"/>
Month Field
The month field can take text input and validate that
the input is a valid month.
Months can be be between 1 and 12.
The browser may also assist the user in picking a
month, by showing a list of months in a textual
representation, localized to the users own language.
You specify that an input field is a date field using the
type="month" attribute, like this:
<input type="month" name="monthField"/>
Week Field
The week field can take text input and validate that the
input is a valid week.
Weeks can be between 1 and 53.
You specify that an input field is a date field using the
type="week" attribute, like this:
<input type="week" name="weekField"/>
Color Field
The color fields are used to select colors, for instance in
a drawing program.
You specify that an input field is a color field using the
type="color" attribute, like this:
<input type="color" name="colorField"/>