Skip to main content
HTML Validation

Attribute “autocomplete” is only allowed when the input type is “color”, “date”, “datetime-local”, “email”, “hidden”, “month”, “number”, “password”, “range”, “search”, “tel”, “text”, “time”, “url”, or “week”.

About This HTML Issue

The autocomplete attribute tells the browser whether and how to automatically fill in a form field based on previously entered data. It makes sense for fields where users type or select values from a predictable set — like names, emails, addresses, dates, and numbers. However, certain input types don’t produce text or numeric data that browsers could meaningfully store and recall. These include checkbox, radio, file, button, submit, reset, and image.

The HTML specification explicitly limits autocomplete to the following input types: color, date, datetime-local, email, hidden, month, number, password, range, search, tel, text, time, url, and week. Using it on any other type violates the spec and produces a validation error.

Why this matters

  • Standards compliance: Browsers are not required to honor autocomplete on unsupported input types, so including it has no practical effect and produces invalid markup.
  • Code clarity: Invalid attributes can confuse other developers reading your code, suggesting a behavior that doesn’t actually exist.
  • Accessibility: Screen readers and assistive technologies rely on valid markup to accurately convey form behavior to users. Unexpected attributes can introduce ambiguity.

How to fix it

  1. Identify the input type that has the autocomplete attribute.
  2. If the type is checkbox, radio, file, button, submit, reset, or image, remove the autocomplete attribute.
  3. If you genuinely need autocomplete behavior, reconsider whether the correct input type is being used. For example, a field that should accept text input might have been incorrectly set to type="checkbox".

Examples

❌ Invalid: autocomplete on a checkbox

<form>
  <label>
    <input type="checkbox" name="terms" autocomplete="off"> I agree to the terms
  </label>
</form>

The browser cannot meaningfully autocomplete a checkbox, so this attribute is not allowed here.

✅ Fixed: remove autocomplete from the checkbox

<form>
  <label>
    <input type="checkbox" name="terms"> I agree to the terms
  </label>
</form>

❌ Invalid: autocomplete on radio buttons

<form>
  <fieldset>
    <legend>Preferred contact method</legend>
    <label>
      <input type="radio" name="contact" value="email" autocomplete="off"> Email
    </label>
    <label>
      <input type="radio" name="contact" value="phone" autocomplete="off"> Phone
    </label>
  </fieldset>
</form>

✅ Fixed: remove autocomplete from radio buttons

<form>
  <fieldset>
    <legend>Preferred contact method</legend>
    <label>
      <input type="radio" name="contact" value="email"> Email
    </label>
    <label>
      <input type="radio" name="contact" value="phone"> Phone
    </label>
  </fieldset>
</form>

❌ Invalid: autocomplete on a file input

<form>
  <label for="resume">Upload resume:</label>
  <input type="file" id="resume" name="resume" autocomplete="off">
</form>

✅ Fixed: remove autocomplete from the file input

<form>
  <label for="resume">Upload resume:</label>
  <input type="file" id="resume" name="resume">
</form>

✅ Valid: autocomplete on supported types

<form>
  <label for="email">Email:</label>
  <input type="email" id="email" name="email" autocomplete="email">

  <label for="bday">Birthday:</label>
  <input type="date" id="bday" name="bday" autocomplete="bday">

  <label for="query">Search:</label>
  <input type="search" id="query" name="query" autocomplete="off">
</form>

If you want to disable autocomplete for an entire form — including checkboxes and other non-text fields — set autocomplete="off" on the <form> element itself rather than on individual inputs that don’t support the attribute:

<form autocomplete="off">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username">

  <label>
    <input type="checkbox" name="remember"> Remember me
  </label>
</form>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries