![]() Capt. Horatio T.P. Webb |
[IE 10 or greater]
Parks -- SPRING 2014 |
HTML 5 -- New Input Elements | ||||||
search | url | tel | number | range (slider) | color | |
date | month | week | time | datetime | datetime-local | |
HTML 5 -- New Attributes | ||||||
placeholder | pattern | required | autofocus | multiple | formnovalidate | novalidate |
HTML 5 -- Related New Events | ||||||
oninvalid |
Results of current browser test are shown like this:
As of 2/22/2014 | IE 10.0.9 | Chrome 33 | Firefox 27 | Opera 18.0.1 | Safari 5.1.7 |
Comments: | GREEN -- When they work. |
OR
As of 2/22/2014 | IE 10.0.9 | Chrome 33 | Firefox 27 | Opera 18.0.1 | Safari 5.1.7 |
Comments: | RED -- When they don't work. |
"The following features are at risk and may be removed due to lack of implementation.
<input type=color>
<input type=datetime>
<input type=month>
<input type=week>
<input type=time>
<input type=datetime-local>..."
Caution: The above are discussed in this document below.
There are several new input types in HTML 5. They extend the original HTML 4.1 types:
The new HTML 5 input types are:
This input type currently performs NO action. It's implementation is incomplete on all browsers and it is treated like a textbox.
HTML for input type="search":
<input type="search" name="freds" size="10">
|
As of 2/22/2014 | IE 10.0.9 | Chrome 33 | Firefox 27 | Opera 18.0.1 | Safari 5.1.7 |
Comments: |
<input type="email" size="40" name="efred">
The validation occurs WITHOUT you having to write the regular expression pattern. It is built-in to the "email" type.
<input type="email" name="fred" size="40" maxlength="40">
<input type="tel" size="40" name="efred">
The validation occurs WITHOUT you having to write the regular expression pattern. It is built-in to the "email" type.
<input type="tel" name="fredphone" size="40" maxlength="40">
See this discussion on the range (aka slider)
<input type="url" size="40" name="ufred">
<input type="url" name="fredlink" size="40" maxlength="40">
The intent is to restrict the input to numeric. This input type currently works correctly in Chrome, is partially implemented in Safari and doesn't work (i.e., doesn't perform a numeric edit) in IE and Firefox.
<input type="number" name="frednum" size="10">
Provides an interactive text box that simplifies date input.
<input type="date" name="freddate" size="10">
Provides an interactive text box that simplifies month input.
<input type="month" name="fredmonth" size="10">
Provides an interactive text box that simplifies week input.
<input type="week" name="fredweek" size="10">
Provides an interactive text box that simplifies time input.
<input type="time" name="fredtime" size="10">
Provides an interactive text box that simplifies datetime input.
<input type="datetime" name="freddatetime" size="10">
HTML for input type="email"
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
must have
...@...must have
...@...must have
...@...must have
...@...no edits
HTML for input type="tel"
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edits
must have
USA phone
patternmust have
USA phone
patternmust have
USA phone
patternno edits
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments: all browsers work
HTML for input type="url"
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
must have
http://...must have
http://...must have
http://...must have
http://...no edits
HTML for input type="number":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edits
must have
numeric
has pickerno edits
must have
numeric
has pickerallows alphabetic
but has picker
HTML for input type="date":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edit
has placeholder
and pickerno edit
has placeholder
and pickerhas placeholder
and picker
HTML for input type="month":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edit
has placeholder
and pickerno edit
has placeholder
and pickerallows alpha
but has picker
HTML for input type="week":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edit
has placeholder
and pickerno edit
has placeholder
and picker allows alpha
but has picker
HTML for input type="time":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edits
has placeholder
and pickerno edit
has placeholder
and pickerallows alpha
but has picker
HTML for input type="datetime":
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
no edits
no edits
no edits
no edits
allows alpha
has picker
The placeholder attribute allows you to place text in an textbox as a guide to the user as to what kind of data to to enter. When the user clicks in the textbox, the placeholder text disapperas and the user can begin entering their text. The placeholder text is normally display in a light gray color.
HTML for input type="text" placeholder="instructional string for the user":
<input type="text" name="fredplacename" size="20" placeholder="Enter your full name">
|
As of 2/22/2014 | IE 10.0.9 | Chrome 33 | Firefox 27 | Opera 18.0.1 | Safari 5.1.7 |
Comments: | ok | ok | ok | ok | ok |
This attribute requires that a user interact with the field by entering data or checking an HTML object before the form is submitted. Its usage is:
<input type="text" name="fred" size="10" maxlength="10" required>
The concept also works for radio buttons, checkboxes and textareas:
<input type="checkbox" name="c1" required>
and
<input type="radio" name="r1" value="1" required>
and
<textarea name="ta" rows="2" cols="12" required></textarea>
When the submit button is clicked and required fields (or actions) have not been provided,
all of the required field are highlighted where the required action has not been taken.
The pattern attribute for HTML input type objects allows the user's input to be validated by regular expressions. The general for is:
<input type="text" pattern="regular expression pattern">
My discussion of regular expressions can be found here. Essentially, a partern is a set of codes to test the content and structure of a string. There is a massive amount of literature on this topic. Regular expressions are used in your email filters to identify spam emails and are have been used extensively in the past for data validation. Both vbscript and javascript (as noted in my page link above) have built in regular expression functionality as part of the scripting language. With this HTML 5 addition, validation can be performed without the use of scripting. Below are some common pattern (see the link above for more details).
<input type="text" pattern="^-{0,1}[0-9]{1,15}\.[0-9]{2}$">
Explanation of the pattern:
<input type="text" pattern="^5[1-5][0-9]{14}$">
Explanation of the pattern:
<input type="text" pattern="^[A-Za-z\s]{1,20}$">
Explanation of the pattern:
The HTML element that gets the focus when the page is loaded.
<input type="text" autofocus>
This attribute should apply to only one HTMl element.
<input type="text" name="fredauto" size="10" maxlength="10" autofocus>
Thsi allows the user to enter more than one value in an element (works ONLY for input types: file and email).
<input type="email" multiple>
<input type="email" name="efred" size="30" maxlength="30">
HTML for input type="text":
HTML for input types "checkbox" and "radio":
<input type="radio" name="r1" value="2" required>
<input type="radio" name="r1" value="3" required>
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
ok
ok
ok
ok
ok
HTML for pattern validation for: an accounting/financial number (i.e., debit/credit):
1. ^-{0,1} means at the begining of the string there is zero or 1 minus, then
2. [0-9]{1,15} means one to fifteen digits 0 through 9, then
3. \. means a single decimal point, then
4. [0-9]{2}$ means two digits at the end of the string
HTML for pattern validation for Master Card credit card number:
1. ^5 must begin with a 5
2. [1-5] followed by 1,2,3,4 or 5
3. [0-9]{14}$ end with 14 digits
HTML for pattern validation for a non-empty alphabetic string 20 or less bytes:
1. [A-za-z\s] means upper case, lower case and white space
2. {1,20}$ means ends with from one to 20 characters
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
ok
ok
ok
ok
none
HTML for input type="text" autofocus:
Click here for the autofocus example
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments:
fails on
load ok
ok
ok
ok
HTML for input type="email" multiple :
As of 2/22/2014
IE 10.0.9
Chrome 33
Firefox 27
Opera 18.0.1
Safari 5.1.7
Comments: