2. Introduction
1/31/2015 2
HTML5 web forms introduced new form elements, input types,
attributes ,and other features.
Many features using in our interfaces: form validation, combo boxes,
placeholder text, and the like.
Marking up forms easier on the developer, also better for the user.
3. Evaluation
Forms section of HTML5 was titled Web Forms 2.0 that added new types for
forms.
Started by Opera and edited by Opera employee Ian Hickson, was submitted
to the W3C in early 2005.
Combined with Web Applications 1.0 to create the basis of Web Hypertext
Application Technology Working Group (WHATWG) HTML5 specification.
1/31/2015 3
4. What are forms?
HTML forms are used to collect user input.
Html form contains form elements.
Example:
<form>
.
form elements
.
</form>
Now Lets look at:
HTML5 New Form Elements
HTML5 New Form Attributes
HTML5 New Element Types
1/31/2015 4
5. Criteria
HTML5 form element must be complete to the following criteria:
It must include pleasant and working UI.
able to use CSS to style the element, especially the UI that we generate.
This includes any pre-defined pseudo-selectors (invalid, required, icon
etc.)
It should be fully accessible.
1/31/2015 5
6. New Form Element
HTML5 added the following form elements:
1. <datalist>
2. <keygen>
3. <output>
1/31/2015 6
7. New Form Element
1. <datalist>
The <datalist> element specifies a list of pre-defined options for an <input> element.
The list is created with <option> elements inside the <datalist>
<form action=“demo.html” method=“get”>
Webpage: <input type=“url” list=“url_list” name=“link” />
<datalist id=“url_list”>
<option label=“W3School” value=http://www.w3schools.com />
<option label=“Googlel” value=http://www.google.com />
<option label=“Yahool” value=http://www.yahoo.com />
</datalist>
<input type=“submit”/>
</form>
1/31/2015 7
8. New Form Element
2. <keygen>
The <keygen> Defines a key-pair key-pair generator field used for forms.
When the form submitted, the private key is stored locally, and the public key is
sent to the server.
The purpose of the <keygen> element is to provide a secure way to authenticate
users.
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security">
<input type="submit">
</form>
1/31/2015 8
9. New Form Element
3. <output>
The <output> tag represents the result of a calculation.
<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>
1/31/2015 9
10. Attributes of the <datalist> element
Attribute Description
contenteditable Specifies whether the content of an element is editable or
not
contextmenu Specifies a context menu for an element. The context menu
appears when a user right-clicks on the element.
hidden Specifies that an element is not yet, or is no longer, relevant.
draggable Specifies whether an element is draggable or not.
dropzone Specifies whether the dragged data is copied, moved, or linked,
when dropped
spellcheck Specifies whether the element is to have its spelling and
grammar checked or not.
Translate Specifies whether the content of an element should be
translated or not
1/31/2015 10
12. Attributes of <keygen> element
1/31/2015 12
Attribute value Description
autofocus autofocu
s
Specifies that a <keygen> element
should automatically get focus when the
page loads
challenge challenge Specifies that the value of the <keygen>
element should be challenged when
submitted
disabled disabled Specifies that a <keygen> element
should be disabled
form form_id Specifies one or more forms the
<keygen> element belongs to
keytype rsa
dsa
ec
Specifies the security algorithm of the
key
name name Defines a name for the <keygen>
element
13. Attribute: name
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security" autofocus>
<input type="submit">
</form>
"Encryption" field automatically get focus when the page loads:
The autofocus attribute of the keygen tag is not supported in Firefox.
Example
1/31/2015 13
14. Attributes of the <output> element
Attribute Value Description
for element_id Specifies the relationship between the
result of the calculation, and the elements
used in the calculation
form form_id Specifies one or more forms the output
element belongs to
name name Specifies a name for the output element
1/31/2015 14
15. Example
Attribute: form, name, for
<form action="demo_form.asp" id="numform"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" id="a" name="a" value="50">100
+<input type="number" id="b" name="b" value="50">
<br><br>
<input type="submit">
</form>
<output form="numform" name="x" for="a b"></output>
Result:
The form attribute of the output element is not supported in any of the major bowsers.
1/31/2015 15
16. HTML5 gives us input types that provide for more data-specific UI elements
and
native data validation. HTML5 has a total of 13 new input types:
1. search
2. email
3. url
4. tel
5. datetime
6. date
7. month
1/31/2015 16
Types of the <input> element
8. week
9. time
10. datetime-local
11. number
12. range
13. color
17. TYPE = SEARCH
<input type> search
The search type is used for search fields
Search type is only supported in Chrome, Opera, and
safari.
Search Google: <input type="search" name="googlesearch" />
1/31/2015 17
18. TYPE = EMAIL
<input type> email
The email type (type="email") is used for specifying one or more email
addresses.
Supports the Boolean multiple attribute, allowing for multiple,
comma-separated email addresses.
Only supported in Chrome, Opera, firefox and safari.
E-mail: <input type="email" name="usermail" />
1/31/2015 18
19. TYPE = URL
<input type> url
The url type is used for input fields that should contain a URL address.
The value of the url field is automatically validated when the form is
submitted.
Search type is only supported in Chrome, Opera, firefox .
Add your homepage: <input type="url" name="homepage" />
1/31/2015 19
20. <input type> tel
For telephone numbers, use the tel input type (type="tel").
Unlike the url and email types, tel type doesn’t enforce a particular
syntax or pattern.
Letters and numbers—indeed, any characters other than new lines or
carriage returns—are valid.
Telephone: <input type="tel" name="usrtel" />
1/31/2015 20
TYPE = TEL
21. TYPE = RANGE
<input type> range
The range input type (type="range") displays a slider control in
browsers .
As with the number type, it allows the min, max, and step attributes.
Define a control for entering a number whose exact value is not
important
<label for="rating">On a scale of 1 to 10, my knowledge of HTML5
is:</label>
<input type="range" min="1" max="10" name="rating" type="range">
1/31/2015 21
22. TYPE = COLOR
<input type> color
The color input type (type="color") provides the user with a color
picker.
Supported only in Opera
Select your favorite color: <input type="color" name="favcolor" />
1/31/2015 22
23. TYPE = KEYGEN
<input type> keygen
The purpose of the <keygen> element provide a secure way to
authenticate users.
The <keygen> specifies key-pair generator field in a form.
When form submitted, two keys generated, one private and other
public.
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name" />
Encryption: <keygen name="security" />
<input type="submit" />
</form>
1/31/2015 23
24. TYPE = OUTPUT
<input type> output
The <output> element represents the result of a calculation (like one
performed by a script).
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" name="a" value="50" />100
+<input type="number" name="b" value="50" />
=<output name="x" for="a b"></output>
</form>
1/31/2015 24
27. Backward Compatibility
The <datalist> element is not supported in Internet
Explorer 9 (and earlier versions), or Safari.
The <keygen> element is not supported in Internet
Explorer.
The <output> element is not supported in Internet
Explorer.
1/31/2015 27
28. CONCLUSION
HTML5 is still work in progress and not due to completely
roll out until the latter part of 2011.
there is no urgency to redesign a Web site using the new
iteration of the language.
Only a handful of major brands, including Mozilla Firefox
and Google Chrome, currently support HTML5 elements.
Those companies’ browsers are only a small fraction of the
browsing populations.
Microsoft’s Internet Explorer is the most widely used
browser and currently has the least amount of support for
HTML5.
1/31/2015 28