Phone number input on mobile

Use type="tel", accept what people type, and tidy it up afterwards.

<label for="ph">Mobile number</label>
<input id="ph" name="phone" type="tel" autocomplete="tel">

Why type="tel"

It opens the phone pad: big digit keys, plus a key for + * #. The pad has no letters and no space, which suits a phone number. Unlike type="number", the value is kept as text, so a leading 0 or + survives.

Do not over-validate

People type phone numbers in many ways: (555) 010-0199, 555.010.0199, +1 555 010 0199. On the iPhone phone pad they cannot type the brackets, dashes or spaces at all. But autofill and paste can bring them in. A strict pattern such as [0-9]{10} rejects perfectly good pasted numbers. Accept the input, strip everything that is not a digit or a leading +, and validate the digits.

Country codes

If you accept international numbers, keep the + key reachable: on the iPhone phone pad it is on the +*# key. A separate country selector with the code shown, such as "+44 United Kingdom", helps people who do not know their own country code. Give it autocomplete="tel-country-code" and the number field autocomplete="tel-national".

Example placeholder trap

A placeholder like 555-010-0199 on a type="tel" field suggests people should type dashes, which the phone pad cannot do. Use a hint below the label instead, such as "Digits only, including area code", or show an example without punctuation. The checker flags placeholders that the keyboard cannot type.

Frequently asked questions

Should a phone field use inputmode="numeric"?

No. type="tel" opens a better pad, includes the + key and tells assistive technology it is a phone number.

Can people type a dash on the iPhone phone pad?

No. The pad has 0–9 and + * #. Dashes only arrive through paste or autofill, so strip them rather than requiring them.

Found a mistake or want a check added? Write to contact (at) mobileformcheck.com.