April 30, 2011 (use the space bar or scroll with your mouse)
See Wufoo's EXCELLENT The Current State of HTML5 Forms (wufoo.com/html5)
(*Still need to validate on the server if you are using one.)
text if the browser doesn't support ittext, password, checkbox, radio, submit, reset, file, hidden, image
select, button, optgroup, option, textarea, label, fieldset, legend
Still okay in HTML5.
search,
tel,
url,
email,
datetime,
date,
color,
month,
week,
time,
datetime-local,
number,
range
accept,
autocomplete,
dirname,
list,
max, min, multiple,
pattern, placeholder,
required, step and more!
Won’t cover all of these. Also: not all attributes apply to all input types.[1]
:checked, :enabled, :disabled, :default, :valid
:invalid, :in-range, :out-of-range, :required, :optional
Awesome forms.
Browser, OS and default errors are language-dependent.
WebKit browsers / Mac
Opera 11 / Ubuntu 10
<input type="email" name="emailaddy" value="" placeholder="placeholder@example.com" required>
<input type="email" name="emailaddy" value="" placeholder="placeholder@example.com" multiple required>
<input type="tel" name="telnum" value=""
placeholder="818-555-1212"
pattern="^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$"
required>
multiple attribute and multiple values are invalid.Demo includes CSS 3 pseudo-classes and an optional field.
<input type="url" name="urlfield" value="" required>
multiple attribute is invalid.
<input type="url" name="urlfield" value=""
placeholder="ftp://"
pattern="^(ftp(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}(?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$""
required>
<input type="range" name="approx" value="" min="0" max="100" step="5">
<input type="text" name="employee" value="" list="employeelist">
<datalist id="employeelist">
<option value="Ray Allen">
<option value="Glenn Davis">
<option value="Kevin Garnett">
</datalist>
setCustomValidity(message) function.checkValidity() function to validate data before form submission. Works better in theory than practice.Keep doing what we have been:
Remember: These attributes are still a part of the DOM tree.