The right keyboard in mobile forms: type, inputmode and autocomplete
Which keyboard opens on a phone is set by the input’s attributes. Use type="tel" for phone numbers and type="email" for email. For fields made of digits that aren’t numbers, such as a ZIP code or routing number, choose type="text" with inputmode="numeric". For amounts, write inputmode="decimal". autocomplete controls autofill, and enterkeyhint the label of the Enter key.
In short
In a mobile form, a keyboard opens every time you tap a field. Which one is up to the browser. You give it a hint with the input’s attributes.
A wrong keyboard looks like a small problem. But it repeats in every field of the form. General form rules are on the form design page. This page covers only the keyboard.
Four attributes, four jobs
These four attributes are often confused, yet each controls something different.
typesays what the data is. According to MDN, theemailandurltypes check the format before submitting;teldoesn’t, because phone numbers vary so much from country to country.inputmodeonly chooses the keyboard. MDN says it clearly: this attribute doesn’t set any validation rule. The default value istext.autocompletetells the browser the field’s purpose. The browser then suggests a saved email or ZIP code.enterkeyhintchooses the label of the Enter key. If it is missing, the browser can choose a label based oninputmode,typeorpattern.
MDN lists eight values for inputmode. I have shortened the descriptions:
| Value | What opens, according to MDN |
|---|---|
none | No virtual keyboard opens. For pages that offer their own input. |
text | Default. The normal keyboard in the user’s language. |
decimal | Digits and the language’s decimal separator. A minus key may be missing. |
numeric | Only the digits 0-9. The minus key depends on the device. |
tel | Phone keypad: 0-9, asterisk (*) and pound (#). |
search | Keyboard optimised for search. The Enter key may say “Search”. |
email | Keyboard optimised for email. The @ character is usually right on the screen. |
url | Keyboard optimised for web addresses. The / key may be prominent. |
For the values tel, email, url and search, MDN gives the same advice. If the field really asks for this data, use the matching type.
For enterkeyhint, MDN lists seven values: enter, done, go, next, previous, search and send. In fields in the middle of a form I use next, in the last field done or send.
Choose a field type
Each of the six fields below is a real input. Open the page on your phone and tap a field, and you see how the keyboard changes. Switch to the bad example and the input’s attributes change too.
Phone
Example: (555) 123-4567
Keyboard on the phone Phone keypad: 0-9, * and #
Bad Normal letter keyboard
<input type="text">
The phone keypad doesn’t open. Autofill doesn’t know what is being asked.
Good Phone keypad: 0-9, * and #
<input type="tel" autocomplete="tel-national" enterkeyhint="next">
The browser can suggest a saved number. Enter usually moves to the next field.
I’ll reply to you here
Keyboard on the phone Email keyboard: usually with an @ key
Bad Normal letter keyboard
<input type="text" autocomplete="off">
The keyboard doesn’t adapt to email. Because autocomplete is off, the browser can’t fill in the saved address itself.
Good Email keyboard: usually with an @ key
<input type="email" autocomplete="email" spellcheck="false" enterkeyhint="next">
The browser checks the format itself. With this type, the first letter isn’t capitalised.
Routing number
9 digits
Keyboard on the phone Number pad: 0-9 only
Bad Number keyboard, often with arrows to increase and decrease
<input type="number">
A routing number isn’t a number you increase or decrease. The user can change the value by accident while doing something else.
Good Number pad: 0-9 only
<input type="text" inputmode="numeric" pattern="[0-9]{9}" maxlength="9" autocomplete="off">
The value stays text. pattern requires 9 digits, and maxlength allows no more.
ZIP code
5 digits, for example 01002
Keyboard on the phone Number pad: 0-9 only
Bad Number keyboard
<input type="number">
A number field treats 01002 as a number, so the leading 0 can be lost. Some ZIP codes in New England and Puerto Rico start with 0.
Good Number pad: 0-9 only
<input type="text" inputmode="numeric" pattern="[0-9]{5}" maxlength="5" autocomplete="postal-code">
The leading 0 is kept. The browser can suggest the saved ZIP code.
Amount
Example: 1,250.50
Keyboard on the phone Decimal keypad: 0-9 and the decimal separator
Bad Number pad: guaranteed only 0-9
<input type="text" inputmode="numeric">
numeric only promises 0-9. The decimal key for the cents may be missing from the keypad.
Good Decimal keypad: 0-9 and the decimal separator
<input type="text" inputmode="decimal" autocomplete="transaction-amount" enterkeyhint="done">
The decimal key for the cents is on the keypad. Enter usually closes the keyboard.
Search
Example: wireless headphones
Keyboard on the phone Normal keyboard, Enter says “Search”
Bad Normal keyboard, the browser chooses the Enter label
<input type="text">
The label may say nothing about search. The user has to guess what happens when they press Enter.
Good Normal keyboard, Enter says “Search”
<input type="search" enterkeyhint="search" autocomplete="off">
The Enter key label says what happens when you press it. Some browsers add a clear icon to the field.
Choose a field type, then switch between Bad and Good. The field is a real input: on a phone, a tap opens the keyboard for these attributes. On desktop, the box under the field names the keyboard that would open. If JavaScript is off, all six fields are listed one below the other with two lines of code each.
A common mistake is type="number" for ZIP codes and routing numbers. People choose it so the number pad opens, but get unwanted behaviour with it. I describe that below.
Fields in the United States
MDN defines the values but doesn’t say which one to choose for US fields. The table below is my suggestion: the format of the fields is documented; the choice of attributes is mine.
| Field | Attributes | Note |
|---|---|---|
| Mobile number | type="tel" autocomplete="tel-national" | No pattern. I accept spaces, dashes and brackets and strip them when saving. |
| Routing number | type="text" inputmode="numeric" pattern="[0-9]{9}" maxlength="9" | There is no autocomplete value for it. I write off. |
| ZIP code | type="text" inputmode="numeric" pattern="[0-9]{5}" autocomplete="postal-code" | Not a number field. The leading 0 must be kept. |
| Card number | type="text" inputmode="numeric" autocomplete="cc-number" | I accept groups of four and strip the spaces when saving. |
| Amount ($) | type="text" inputmode="decimal" | In a payment form I add autocomplete="transaction-amount". |
Phone. The United States is part of the North American Numbering Plan, with country code 1. Numbers have ten digits: a three-digit area code and a seven-digit local number. Users write them as “(555) 123-4567”, “555-123-4567” or “5551234567”. Accept all of them.
According to MDN, tel-national is a number without the country code. If you also accept international numbers, use tel: MDN describes it as a full number including the country code.
Routing number. An ABA routing number has nine digits. There is no value for it in MDN’s list of autocomplete values. inputmode="numeric" is enough for the number pad.
ZIP code. A ZIP code has five digits; the ZIP+4 form adds four more. Some ZIP codes start with 0, such as 01002 for Amherst, Massachusetts, and that 0 mustn’t be lost. MDN also counts postal codes among the values that type="number" doesn’t suit.
Card number. MDN names credit card numbers as another value that consists only of digits but isn’t really a number. Card numbers are usually written in groups of four; the form should allow typing them that way.
According to MDN, pattern has to match the whole value. Also describe the format in visible text at the field. MDN considers that essential for accessibility.
The type="number" trap
According to MDN, the number type is meant only for numbers that are incremented and decremented. It doesn’t suit values that consist only of digits but aren’t really a number. MDN names postal codes and credit card numbers as examples.
The same page names two risks. Users can change the number by accident while trying to do something else. And if they type something that isn’t a number, they don’t see clearly what they did wrong.
MDN recommends type="text" together with inputmode="numeric" and a pattern. One more note: the pattern attribute doesn’t work with the number type.
For amounts, use decimal, not numeric. numeric only promises 0-9, and the decimal key for the cents may be missing. decimal also shows the decimal separator of the user’s language.
My note
In audits I also look at forms on a phone and note the keyboard as a point of its own. Most often I find that every field opens the same letter keyboard. The developer usually wrote type="text" and moved on.
The second most common mistake: autocomplete="off" on the email and phone fields of the sign-up form. According to MDN, off stops the browser from filling in the value, and the user types everything by hand. I only use this value in fields such as a routing number that the browser doesn’t know anyway.
Once the keyboard is right, another problem shows up: the open keyboard covers part of the screen. To keep fields and buttons easy to tap, see the touch target page. When error messages should appear is described on the inline validation page.
A note on accessibility
WCAG 2.2 success criterion 1.3.5 Identify Input Purpose is level AA. If the purpose of a field that collects information about the user is one of the input purposes listed in the standard, it must be programmatically determinable. The W3C’s sufficient techniques include the HTML autocomplete attribute.
The W3C sees autofill as an important help for users with memory problems or dyslexia, and users with motor impairments type less. I see the right keyboard as part of the same work. All the criteria are covered in the WCAG guide.
autocapitalize changes nothing on a physical keyboard; it affects virtual keyboards and methods such as voice input. According to MDN, letters aren’t capitalised anyway with the email, url and password types. So you don’t need autocapitalize in the email field.
Checklist
Before a form goes live, I tap every field on a phone one by one and go through this list.
- The phone field has type="tel", and the phone keypad opens.
- The email field has type="email", and the email keyboard opens.
- Fields for routing number, ZIP code and card number don’t use type="number".
- In the amount field, the keyboard shows the decimal separator.
- Fields with personal information have the right autocomplete value.
- Next to a field with a pattern, the format is described in text.
- In the last field, the Enter key has a label that fits finishing.
If you want me to do this check: the UX audit includes the mobile points too. If you check yourself, start with the UX audit checklist.
Questions
What is the difference between inputmode and type?
type sets the kind of data and checks the format for types such as email and url. inputmode only says which virtual keyboard opens and sets no rule.
Which input type suits phone numbers?
Use type="tel". According to MDN, mobile browsers show a suitable keypad for this type. For US numbers without the country code, add autocomplete="tel-national".
Should a ZIP code use type="number"?
No. A ZIP code isn’t a number you increase or decrease, and a leading 0 can be lost. Use type="text", inputmode="numeric" and pattern="[0-9]{5}".
Does inputmode change anything on desktop?
Not on a physical keyboard, because no virtual keyboard opens. It doesn’t check the value either. The effect shows on the virtual keyboard of touch devices.
Sources (12)
- MDN Web Docs, inputmode (HTML global attribute). accessed 2026-11-04
- MDN Web Docs, enterkeyhint (HTML global attribute). accessed 2026-11-04
- MDN Web Docs, <input>: The HTML Input element. accessed 2026-11-04
- MDN Web Docs, <input type="tel">. accessed 2026-11-04
- MDN Web Docs, <input type="number">. accessed 2026-11-04
- MDN Web Docs, <input type="search">. accessed 2026-11-04
- MDN Web Docs, HTML attribute: autocomplete. accessed 2026-11-04
- MDN Web Docs, autocapitalize (HTML global attribute). accessed 2026-11-04
- W3C, Understanding Success Criterion 1.3.5: Identify Input Purpose (WCAG 2.2). accessed 2026-11-04
- Wikipedia, North American Numbering Plan. accessed 2026-11-04; country code 1, ten-digit numbers
- Wikipedia, ABA routing transit number. accessed 2026-11-04; nine digits
- Wikipedia, ZIP Code. accessed 2026-11-04; five digits, ZIP+4, low codes such as 01002