Better forms with autocomplete, inputmode and enterkeyhint

Let browsers fill in forms for people, and show the right on-screen keyboard for every field.

  • Beginner
  • 6 min read
  • Updated 17 Oct 2026

What you will learn

  • Set autocomplete tokens correctly
  • Show the right on-screen keyboard
  • Support password managers and one-time codes

Before you start

Typing on a phone is slow and error-prone. Three attributes make forms much faster to complete: autocomplete lets the browser fill in known details, inputmode picks the on-screen keyboard, and enterkeyhint labels the Enter key. None of them change validation or what is sent; they only help people get the data in.

autocomplete

Browsers remember names, addresses, email addresses, phone numbers and payment cards. The autocomplete attribute tells them exactly which piece of information a field wants:

HTML
<label for="email">Email address</label>
<input id="email" name="email" type="email" autocomplete="email">

Browsers try to guess from name, id and label text, but the guesses are often wrong. An explicit token removes the guesswork, and with one tap the whole form can be filled correctly.

It also helps accessibility. WCAG success criterion 1.3.5 (Identify Input Purpose) asks that fields collecting information about the user identify their purpose, and the autocomplete tokens are how HTML does that. People with cognitive or motor impairments benefit most from not having to type.

Common tokens

TokenField
nameFull name in one field
given-name, family-nameFirst and last name in separate fields
emailEmail address
telFull phone number including country code
organizationCompany name
street-addressFull street address in one textarea
address-line1, address-line2Street address split over lines
address-level2Town or city
postal-codePostcode or ZIP code
country-nameCountry
bdayDate of birth
usernameUsername or account email for sign-in
current-passwordThe existing password on a sign-in form
new-passwordA new password on a sign-up or change-password form
one-time-codeA code sent by SMS or an authenticator app
cc-name, cc-number, cc-exp, cc-cscPayment card name, number, expiry and security code

The full list is in the HTML specification. Use the exact spelling: organization with a "z" is the token, whatever your house style.

Sections and contact types

You can add qualifiers before the main token:

  • shipping or billing to tell two addresses apart: autocomplete="shipping postal-code".
  • section- followed by any name, to group fields that belong together, such as two different people on one form.
  • home, work or mobile before contact tokens: autocomplete="work email".

Turning autofill off

autocomplete="off" asks the browser not to save or fill the field. Use it sparingly, for values that are never about the user, such as a search filter or a one-off reference number. Browsers may ignore it on sign-in fields, because blocking password managers makes accounts less secure.

Do not use autocomplete="off" to stop people pasting or saving passwords. Password managers encourage long, unique passwords. Marking password fields with current-password and new-password helps them work properly.

A checkout form

HTML
<!DOCTYPE html>
<html lang="en-GB">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Delivery details | Riverside Bakery</title>
</head>
<body>
  <h1>Delivery details</h1>
  <form action="/checkout" method="post">
    <p>
      <label for="full-name">Full name</label>
      <input id="full-name" name="full-name" type="text" autocomplete="name" enterkeyhint="next" required>
    </p>
    <p>
      <label for="email">Email address</label>
      <input id="email" name="email" type="email" autocomplete="email" enterkeyhint="next" required>
    </p>
    <p>
      <label for="phone">Phone number</label>
      <input id="phone" name="phone" type="tel" autocomplete="tel" enterkeyhint="next">
    </p>
    <p>
      <label for="address">Street address</label>
      <textarea id="address" name="address" rows="3" autocomplete="shipping street-address" required></textarea>
    </p>
    <p>
      <label for="town">Town or city</label>
      <input id="town" name="town" type="text" autocomplete="shipping address-level2" enterkeyhint="next" required>
    </p>
    <p>
      <label for="postcode">Postcode</label>
      <input id="postcode" name="postcode" type="text" autocomplete="shipping postal-code" autocapitalize="characters" enterkeyhint="done" required>
    </p>
    <button type="submit">Continue to payment</button>
  </form>
</body>
</html>

inputmode: choose the keyboard

type defines what the data is. inputmode only chooses which virtual keyboard to show on touch devices. It is useful when the right type does not exist or has side effects.

ValueKeyboard
textStandard text keyboard (the default)
numericDigits only
decimalDigits and a decimal separator
telTelephone keypad
emailText keyboard with @ and .
urlText keyboard with / and .
searchText keyboard with a search-style Enter key
noneNo keyboard, for fields with their own custom input

The classic use is numbers that are not quantities:

HTML
<label for="card">Card number</label>
<input id="card" name="card" type="text" inputmode="numeric" autocomplete="cc-number">

<label for="code">Verification code</label>
<input id="code" name="code" type="text" inputmode="numeric" autocomplete="one-time-code" maxlength="6">

type="text" keeps leading zeros and spaces, avoids the spinner arrows of type="number", and inputmode="numeric" still shows the digit keypad. On many phones, one-time-code also lets the keyboard suggest the code from a text message.

Do not use inputmode when the right type exists. For an email field, type="email" already shows the email keyboard and adds validation.

If you validate digits with pattern="[0-9]*", pair it with inputmode="numeric". The pattern checks the value; the input mode only changes the keyboard.

enterkeyhint: label the Enter key

On virtual keyboards, the Enter key can show a word or icon that says what will happen:

ValueTypical meaning
enterInsert a new line
doneFinish and close the keyboard
goGo to the typed destination
nextMove to the next field
previousMove to the previous field
searchRun a search
sendSend a message
HTML
<label for="q">Search the menu</label>
<input id="q" name="q" type="search" enterkeyhint="search">

enterkeyhint only changes the label. It does not move focus to the next field or submit the form; that behaviour is still up to the browser and any script you write. Make sure the hint matches what really happens, and treat it as a nice extra rather than something to rely on, since keyboards display it in different ways.

autocapitalize and spellcheck

Two more attributes help with specific fields:

  • autocapitalize controls automatic capitals on virtual keyboards: none, sentences, words or characters. Use characters for postcodes and none for usernames.
  • spellcheck="false" stops the red underline on fields such as usernames, codes and email addresses, where spelling suggestions are unhelpful.

Summary

  • Add an exact autocomplete token to every field that collects details about the user.
  • Use current-password, new-password and one-time-code so password managers and code autofill work.
  • Use type for the kind of data and inputmode only to pick the keyboard, typically numeric for card numbers and codes.
  • Use enterkeyhint to label the Enter key; it does not change behaviour.
  • Reserve autocomplete="off" for fields that are never about the user.

Further reading