# Bad value “” for attribute “autocomplete” on element “input”: Must not be empty.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-for-attribute-autocomplete-on-element-input-must-not-be-empty
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `autocomplete` attribute tells the browser whether and how it should autofill a form field. The HTML living standard defines a specific set of allowed values — an empty string is not among them. When the attribute is present but empty, the browser receives ambiguous instructions: you've explicitly declared the attribute, signaling intent, but provided no actual directive. Different browsers may interpret this inconsistently, some treating it as `on`, others ignoring it, and others falling back to default behavior.

This matters for several reasons:

- **Standards compliance**: The WHATWG HTML specification requires `autocomplete` to contain either the keywords `on` or `off`, or one or more valid autofill detail tokens. An empty string satisfies none of these.
- **Accessibility**: Autofill helps users with motor impairments or cognitive disabilities complete forms more quickly and accurately. An ambiguous `autocomplete` value can interfere with assistive technologies that rely on these hints.
- **User experience**: Specific autofill tokens like `email`, `tel`, `street-address`, and `current-password` allow browsers and password managers to suggest the right data for the right field. Using them correctly makes forms faster and easier to complete.

This issue commonly arises when a framework or template engine outputs `autocomplete=""` as a default, or when a developer intends to disable autocomplete but leaves the value blank instead of using `off`.

## How to fix it

Choose one of these approaches depending on your intent:

1. **Remove the attribute** if you want default browser behavior (the browser decides whether to autofill).
2. **Use `on`** to explicitly allow autofill.
3. **Use `off`** to explicitly discourage autofill (note: browsers may still autofill for login fields regardless).
4. **Use a specific autofill token** to tell the browser exactly what kind of data the field expects. This is the most helpful option for users.

Common autofill tokens include: `name`, `given-name`, `family-name`, `email`, `username`, `new-password`, `current-password`, `tel`, `street-address`, `postal-code`, `country`, and `cc-number`. You can find the full list in the [WHATWG autofill specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).

## Examples

### Incorrect: empty autocomplete value

```html
<input type="text" name="username" autocomplete="">
```

This triggers the validation error because the attribute is present but contains no valid token.

### Correct: remove the attribute entirely

If you have no specific autofill preference, simply omit the attribute:

```html
<input type="text" name="username">
```

### Correct: use `on` or `off`

Explicitly enable or disable autofill:

```html
<input type="text" name="username" autocomplete="on">
```

```html
<input type="text" name="search-query" autocomplete="off">
```

### Correct: use specific autofill tokens

Specific tokens give browsers the best hints for filling in the right data. This is the recommended approach for forms that collect personal information:

```html
<form>
  <label for="name">Full name</label>
  <input type="text" id="name" name="name" autocomplete="name">

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

  <label for="phone">Phone</label>
  <input type="tel" id="phone" name="phone" autocomplete="tel">

  <label for="pwd">Password</label>
  <input type="password" id="pwd" name="pwd" autocomplete="current-password">

  <button type="submit">Sign in</button>
</form>
```

Using precise tokens like `current-password` and `email` helps password managers and mobile keyboards provide the most relevant suggestions, improving the experience for all users.
