FRM-014 Give email, phone and web address fields the input type that matches the value
- Level
- Guideline, our choice
- Verdict
- Insufficient evidence (1 of 3 judges spoke)
- Area
- Forms
- Status
- proposed, version 1.0.0
Rule
Give a field that asks only for an email address type="email", a field for a phone number type="tel" and a field for a web address type="url". A phone or tablet then shows a keyboard with the keys that value needs.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: The type that matches each value
autocomplete value. The line under a field shows the keyboard a phone would pick. Everything is still typed as before on a computer. The web address is typed without https://: the form has its own check turned off and adds the scheme itself, as the last line shows.Don't: Every field left as text
Don't: The type in place of the autocomplete value
autocomplete value, so the code never states its purpose. The type picks the keyboard; only autocomplete says what the field is for.Do: A field that takes a user name stays text
Don't: An email type on Email or username
Why
On a phone, the standard keyboard puts the at sign, the dot, the slash and the digits behind a second or third layout. Typing an email address or a phone number on it means switching layouts again and again, and every switch is a chance to hit the wrong key. The input type tells the browser what kind of value the field holds, and the browser picks a keyboard that has those keys on its first layout. On a computer with a physical keyboard the type changes nothing for typing.
The type is not the field's purpose. WCAG 2.2, 1.3.5 Identify Input Purpose is met by the autocomplete value that FRM-007 asks for, never by the type. A field with the right type and no autocomplete value can still fail 1.3.5, and a field without the type does not fail it. The two go together: the type picks the keyboard, the autocomplete value lets the browser fill the field in.
Our reasons
Fewer than two judges have spoken about which keyboard a field calls up, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Apple supports it. So does GOV.UK, an expert witness who does not vote. Material and Carbon are silent, which is not a vote against. We ask for the type for three reasons.
- Fewer layout switches. The right keys on the first layout save taps on every field, and they matter most to people with motor or dexterity difficulties, for whom each extra tap is slow and can go wrong.
- It costs nothing. The type is one attribute. It does not change how the field looks, and on a desktop it does nothing for typing.
- Fewer typos in values that must be exact. An email address or a phone number with one wrong character reaches nobody, and the person often finds out only when a confirmation never arrives. Keys that are easy to reach make that slip less likely.
Do
- On the form Become a supplier for a weekly food market, Email is
<Input type="email" autoComplete="email" />, Mobile number is<Input type="tel" autoComplete="tel" />and Shop website is<Input type="url" autoComplete="url" />. Each field keeps its visible label, as FRM-001 asks, and theautocompletevalues follow FRM-007. - Let Mobile number take spaces, brackets, dashes and a leading plus sign.
type="tel"only picks the keyboard; it does not check the format. Check the value in your own code, as FRM-002a and FRM-002b describe. - Our own advice: let Shop website take an address typed without
https://, such as "fieldandfork.example", and add the scheme yourself. People seldom type it. Becausetype="url"makes the browser refuse an address without a scheme, this only works with the browser's own check turned off. - Turn the browser's own check off on the form with
noValidate, as FRM-007 says, and show errors at the field and after a failed send as FRM-002a, FRM-002b and FRM-011 describe. - Keep
type="email"on the field when a zod schema already checks the address. The schema checks the value; the type picks the keyboard. They do different jobs. - Trim spaces from an email address in your own code before you check it. Some browsers trim them in an email field and some may refuse an address with letters outside ASCII; test the addresses your users have.
Don't
- Leave Email, Mobile number and Shop website at the default text type, so every one opens the letters keyboard.
- Give Mobile number
type="number". A phone number is not a quantity; FRM-014b keeps it out of a number input. - Use the type in place of the
autocompletevalue. Email withtype="email"and noautoComplete="email"still lacks its purpose (FRM-007). - Give Email or username on a sign-in form
type="email". The browser's check would refuse a user name, and the keyboard would suit only half of what the field takes.
Exceptions
- Fields that take more than one kind of value. A field that accepts an email address or something else, such as a user name, stays
type="text". - Digits and numbers. Fields that take only digits, such as codes and card numbers, are FRM-014a for the keypad and FRM-014b for the type. A phone number is covered here.
- Search fields. Whether a search field is
type="search"is a question of role, not of keyboard, and is outside this guideline. - A product that chooses otherwise. This is a guideline. A field without the type still needs its label (FRM-001) and its
autocompletevalue (FRM-007).
Verdict
Insufficient evidence (1 of 3 judges spoke). Only the judges decide; the expert witnesses are shown but do not vote. The judges do not settle this one, so it is a guideline: our own choice, with our reasons above. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 1.3.5 Identify Input Purpose |
| Material Design | Judge | No position | |
| Apple Human Interface Guidelines | Judge | Supports | Virtual keyboards (ios, ipados, tvos, visionos, watchos; no web guidance) Text fields |
| Carbon Design System | Judge | No position | |
| GOV.UK Design System | Expert witness | Supports | Email addresses Phone numbers |
| Nielsen Norman Group | Expert witness | No position |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Forms: 15 rules and 12 guidelines · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.