About This HTML Issue
The autocomplete attribute on <form> elements controls whether the browser should automatically fill in form fields based on previously entered data. Unlike autocomplete on <input> elements — which accepts a rich set of tokens like "name", "email", "street-address", etc. — the <form> element itself only accepts two values: "on" and "off".
A common workaround that gained popularity was setting autocomplete="nope" (or other made-up values like "new-password", "false", or "disabled") on the <form> element. This hack exploited the fact that some browsers would treat any unrecognized value as a signal to disable autocomplete. However, this behavior is non-standard and unreliable — browsers may ignore invalid values entirely and fall back to their default behavior, which is typically "on".
Using invalid attribute values causes several problems:
- Standards compliance: The HTML specification explicitly defines the allowed values, and validators will flag anything else as an error.
- Unpredictable behavior: Different browsers handle invalid values differently. What works in one browser today may stop working in the next update.
- Accessibility and user experience: Assistive technologies and browser features rely on standard attribute values to function correctly. Invalid values can interfere with password managers and autofill tools that many users depend on.
It’s worth noting that even with autocomplete="off", some browsers (particularly Chrome) may still autofill certain fields like login credentials for security reasons. If you need finer-grained control, apply autocomplete attributes directly on individual <input> elements using the appropriate autofill tokens from the specification.
Examples
❌ Invalid: Using a made-up value on a form
<form autocomplete="nope" action="/submit" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username">
<button type="submit">Submit</button>
</form>
This triggers the error Bad value “nope” for attribute “autocomplete” on element “form” because "nope" is not a valid autocomplete value for <form>.
✅ Fixed: Using the correct value to disable autocomplete
<form autocomplete="off" action="/submit" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username">
<button type="submit">Submit</button>
</form>
✅ Using autocomplete on individual inputs for more control
If you need to disable autocomplete for specific fields while leaving others enabled, apply the attribute directly on the <input> elements instead:
<form action="/submit" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username" autocomplete="username">
<label for="secret">One-time code</label>
<input type="text" id="secret" name="secret" autocomplete="off">
<button type="submit">Submit</button>
</form>
In this example, the username field uses the standard "username" autofill token to help browsers fill it correctly, while the one-time code field has autocomplete disabled since its value should never be reused.
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.
Learn more: