Skip to content

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

Each field has a visible label, the type that fits its value and its own 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

All three fields open the standard letters keyboard on a phone, so the at sign, the dot, the digits and the slash sit behind a layout switch. Nothing looks different here, which is why the line under each field is the only place the miss shows.

Don't: The type in place of the autocomplete value

The keyboard is right, but the field has no 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

Email or username takes more than one kind of value, so it keeps the text type. Its user name goes through. Compare the next example.

Don't: An email type on Email or username

The browser's own check refuses the user name, as the line under the field shows, and the keyboard suits only half of what the field takes. Replace the text with an address to see the check accept it.

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 the autocomplete values 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. Because type="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 autocomplete value. Email with type="email" and no autoComplete="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 autocomplete value (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

Stances on FRM-014
SourceRoleStancePage
WCAG 2.2LawSupports1.3.5 Identify Input Purpose
Material DesignJudge No position
Apple Human Interface GuidelinesJudge SupportsVirtual keyboards (ios, ipados, tvos, visionos, watchos; no web guidance)
Text fields
Carbon Design SystemJudge No position
GOV.UK Design SystemExpert witness SupportsEmail addresses
Phone numbers
Nielsen Norman GroupExpert 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