Back to HTML

Mobile Keyboards, inputmode and autocomplete

Coding Tutorials Team 26 June 2026

A large share of forms are completed on a phone, where typing is slow and error prone. Two attributes make a substantial difference to that experience and are frequently omitted because neither has any visible effect on a desktop.

Why inputmode exists

The type attribute already influences the keyboard, so a number type produces a numeric keypad. The problem is that type also brings validation and interface behaviour that may be unwanted.

A card number is a good example. It consists of digits, so the number type seems right, and it will then strip leading zeros, reject the spaces people naturally type, and display stepper arrows that make no sense. What you actually want is a text field with a numeric keyboard.

<input type="text" inputmode="numeric" autocomplete="cc-number" id="card" name="card">

The inputmode attribute separates the keyboard from the type, which is exactly the separation this case needs.

The available values

Numeric gives digits only, which suits codes, postcodes and quantities. Decimal adds a decimal separator for amounts. Tel produces a telephone keypad including the symbols used in phone numbers. Email and url add the characters common to each. Search changes the return key to a search action. Text and none cover the remaining cases.

Choosing the right one saves the user from switching keyboard layouts repeatedly, which on a long form is a real irritation.

The enter key hint

A companion attribute changes the label on the return key, which sets expectations about what pressing it will do.

<input type="search" inputmode="search" enterkeyhint="search">

Values include next, done, go, search and send. Using next on every field except the last, with done on the final one, makes a multi-field form noticeably smoother to work through.

Autocomplete does more than you think

The autocomplete attribute is often treated as a switch to turn autofill off. It is actually a vocabulary describing what each field contains, and used properly it lets the browser fill a form accurately in one action.

<input autocomplete="given-name" ...> <input autocomplete="family-name" ...> <input autocomplete="email" ...> <input autocomplete="street-address" ...> <input autocomplete="postal-code" ...>

There are dozens of defined tokens covering names, addresses, telephone numbers, payment details and one-time codes. Without them the browser guesses from field names and ids, and it guesses wrongly often enough that users end up correcting a half filled form, which is worse than filling it themselves.

Passwords and one-time codes

Login forms should mark the username field and use current-password on the password field. Registration and change forms should use new-password, which tells a password manager to offer to generate one rather than filling in the existing value.

For verification codes sent by message, the one-time-code token allows the browser or operating system to offer the code directly from the notification. This removes an app switch and a manual copy, and it costs one attribute.

Turning it off is usually wrong

Disabling autocomplete across a whole form is a widespread habit with weak justification. It is sometimes done for security reasons that do not hold up, since a password manager filling a field is safer than a user typing a password they can remember.

Legitimate cases exist: a field where a previously stored value would be actively wrong, or a one-off reference that should never be remembered. These are the exception rather than a default worth applying broadly.

Field size and zoom

One more mobile detail. Some browsers zoom the page when focusing an input whose font size is below sixteen pixels, which is jarring and leaves the layout shifted afterwards.

Setting form controls to at least that size prevents it. It is a small change that removes a specific annoyance many people never trace to its cause.

Label the fields the browser expects

Autofill works best when the form matches conventional patterns. Splitting an address across the fields the token vocabulary describes, in a familiar order, lets the browser map its stored data onto your form.

Unusual arrangements defeat it. A single field asking for a full address, or a name split into three parts in an unexpected order, gives the browser nothing to match against, and the user types everything by hand. Where a design calls for something unconventional, the tokens are what tell the browser what each part means, so they matter more rather than less.

Test on a real device

None of this is visible in a desktop browser, and the device simulator in developer tools does not show the actual keyboard. The only way to know whether a form is pleasant to complete on a phone is to complete it on a phone, which takes two minutes and reliably finds problems no amount of desktop testing reveals.