M2 Part5
M2 Part5
Forms
2
HTML5 Forms
Number
<input type="number"/>
<input type="number" name="points" min="1" max="10" />
4
Input Types
The range type is displayed as a slider bar.
Range
<input type="range" name="points" min="1" max="10" />
5
Common Types
Textarea
<textarea rows="8" cols="20"></textarea>
Check Box
<input type="checkbox" name="x[]" value="h"/>
6
Input Types
Password
<input type="password"/>
Email
<input type="email"/>
7
Date
Date
<input type="date"/>
date - Selects date, month and year
> month - Selects month and year
> week - Selects week and year
> time - Selects time (hour and minute)
> datetime - Selects time, date, month and year
> datetime-local - Selects time, date, month and
year (local time)
8
Date time
<form action="/action_page.php">
Birthday (date and time):
<input type="datetime-local" name="bdaytime">
</form>
9
Select list
Option
<select name="country">
<option value="" selected="selected"
disabled="disabled">Select your
country</option>
<option value="1">India</option>
<option value="2">Pakistan</option> </select>
10
Group Box
Group box labels an entire collection of radio buttons.
A group box - a set of fields indicate a common group.
Syntax:
<fieldset>
<legend align=“top”>legend text</legend>
collection of fields
</fieldset>
11
Syntax
<input type=“hidden” name=“name”
value=“value>
Color Picker
Input fields that should contain a color.
Syntax:
Color: <input type="color" name="user_color" />
15
Example
<form>
Select your favorite color:
<input type="color" name="favcolor" value="#ff0000">
<input type="submit">
</form>
16
tel
<form>
Telephone: <input type="tel" name="phone"
pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" required>
<input type="submit">
<span>Format: 123-45-678</span>
</form>
17
Keygen - Security
keygen element is used to provide a secure way to authenticate
users.
(keytype:rsa,dsa,ec)
Output Attribute
The output element is used for different types of output, like
calculations or script output:
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0<input type="range" id="a" value="50">100
+<input type="number" id="b" value="50">
=<output name="x" for="a b"></output>
</form>
20
Submit
<input type="submit" value="Save My Data"/>
Reset
<input type="reset" value="Reset Data"/>
Example - Forms
22
THANK YOU