Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The browser still autofills a React input marked autoComplete off

Error<input autoComplete="off" /> still shows saved suggestions or a filled password

Short answer

React does pass autoComplete to the DOM as the autocomplete attribute. The browser, not React, decides whether to obey it, and it may ignore off on login fields so password managers keep working. Use the value that describes the field, such as new-password or one-time-code.

  • Applies to React 19, Chrome, Firefox
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Inspect the input in the browser developer tools and check which autocomplete attribute is on the real element.

    document.querySelector('input').getAttribute('autocomplete')
  2. 2Match what you see, then jump to its fix

    1. 1Only username or password inputs are filledThe browser ignores off on login and password fieldsFix
    2. 2The attribute holds a random string meant to fool autofillA made-up value is used instead of a defined oneFix
    3. 3One input fills while its neighbours do notoff is set on the field but the form says otherwiseFix

What does the error look like?

  • <input autoComplete="off" /> still shows saved suggestions or a filled password
  • Browser asks to save the password for a form that sets autocomplete off

Cause 1 of 3

The browser ignores off on login and password fields

1Check

MDN says browsers may ignore off on login fields to support password managers, and most modern browsers still offer to save and fill credentials.

document.querySelector('input[type=password]').autocomplete

2Fix

Use the token that matches the purpose: new-password for a registration or reset field, current-password for sign-in.

<input type="password" name="password" autoComplete="new-password" />

3Verify

Reload and open the field; the browser treats it as a new password.

npm run dev

Confirmed by developer.mozilla.org

Did this fix it?

Cause 2 of 3

A made-up value is used instead of a defined one

1Check

MDN says invalid or non-standard values mean the browser cannot match the field to any purpose.

grep -rn "autoComplete=" src | grep -v "off\|new-password\|current-password\|one-time-code"

2Fix

Use a standard token. For an SMS or email code, one-time-code describes it.

<input name="otp" inputMode="numeric" autoComplete="one-time-code" />

3Verify

Check the rendered attribute in the inspector.

document.querySelector('[name=otp]').getAttribute('autocomplete')

Confirmed by developer.mozilla.org

Did this fix it?

Cause 3 of 3

off is set on the field but the form says otherwise

1Check

An input with no autocomplete attribute takes the value of its owning form, so a form-level setting applies to every field that has none of its own.

document.querySelectorAll('form, input').forEach(e => console.log(e.tagName, e.name, e.getAttribute('autocomplete')))

2Fix

Set the attribute on the form, or on every input that needs it, and keep a name or id on each input.

<form autoComplete="off">
  <input name="coupon" />
</form>

3Verify

Reload and focus the field.

npm run dev

Confirmed by developer.mozilla.org

Did this fix it?

How do I stop it coming back?

  • Reserve off for fields where stored values are wrong, such as one-time tokens.
  • Describe each field with the proper autocomplete token instead of fighting the browser.
  • Check the attribute on the live DOM when behaviour differs from your JSX.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.