Skip to main content
Validação HTML

Bad value “nothanks” for attribute “autocomplete” on element “input”: The string “nothanks” is not a valid autofill field name.

Sobre este problema HTML

The autocomplete attribute tells browsers whether and how to autofill a form field. The HTML specification defines a strict set of valid values for this attribute, known as autofill field names. These include values like "on", "off", "name", "email", "username", "new-password", "current-password", "address-line1", "postal-code", "cc-number", and many others. When you use a value that doesn’t appear in this list — such as "nothanks", "nope", or "false" — the W3C validator reports it as an invalid autofill field name.

A common reason developers use made-up values is frustration with browsers ignoring autocomplete="off". Some browsers (notably Chrome) may still autofill certain fields even when autocomplete="off" is set, particularly for login-related fields. This has led to workarounds using random strings, but these are non-standard and can produce unpredictable behavior across different browsers and assistive technologies.

Why This Matters

  • Standards compliance: Invalid attribute values make your HTML non-conforming, which can lead to unexpected browser behavior now or in the future.
  • Accessibility: Screen readers and other assistive technologies may use the autocomplete attribute to help users fill in forms. A recognized value like "name" or "email" gives these tools meaningful context, while a random string provides none.
  • Browser behavior: Browsers are designed to interpret the standard values. An unrecognized value may be treated inconsistently — some browsers might ignore it, others might treat it as "on", and behavior could change between versions.

How to Fix It

If you want to disable autocomplete, use "off":

<input type="text" name="search" autocomplete="off">

If you want to help browsers autofill correctly, use the appropriate autofill field name from the specification:

<input type="email" name="email" autocomplete="email">

If autocomplete="off" isn’t being respected by the browser (a known issue with some login fields in Chrome), consider these standards-compliant alternatives:

  • Use autocomplete="new-password" on password fields where you don’t want saved passwords suggested.
  • Use a more specific valid token that doesn’t match what the browser is trying to autofill.
  • Use the readonly attribute and remove it on focus via JavaScript as a supplementary measure.

Examples

❌ Invalid: arbitrary string as autocomplete value

<form>
  <label for="firstName">First name</label>
  <input type="text" name="firstName" id="firstName" autocomplete="nothanks">

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

Both "nothanks" and "nope" are not valid autofill field names and will trigger the validation error.

✅ Valid: using "off" to disable autocomplete

<form>
  <label for="firstName">First name</label>
  <input type="text" name="firstName" id="firstName" autocomplete="off">

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

✅ Valid: using proper autofill field names

<form>
  <label for="firstName">First name</label>
  <input type="text" name="firstName" id="firstName" autocomplete="given-name">

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

  <label for="newPass">New password</label>
  <input type="password" name="newPass" id="newPass" autocomplete="new-password">
</form>

Using descriptive autofill tokens like "given-name", "email", and "new-password" is the best approach when you want browsers and assistive technologies to understand your form fields. For a complete list of valid autofill field names, refer to the WHATWG HTML specification’s autofill section.

Encontre problemas como este automaticamente

O Rocket Validator analisa milhares de páginas em segundos, detetando problemas HTML em todo o seu site.

Ajude-nos a melhorar os nossos guias

Este guia foi útil?

Pronto para validar os seus sites?
Comece o seu teste gratuito hoje.