Stopping Chrome from ignoring autocomplete=off
Autofill (or autocomplete) attributes tell browsers to automatically fill out an answer for the user if the user has stored that information in the browser.
And this little feature saves users well over a million days per month .
But there’s a problem with Chrome: it sometimes ignores autocomplete="off"
.
Now even though this is annoying, it might be the right thing to do and it may also be abiding by the specification.
The autocomplete content attribute can be used to hint to the user agent how to, or indeed whether to, provide such a feature.
This is because with HTML, this attribute (like any other), is a suggestion to the browser.
To make things a little more complicated, browsers may also autofill form fields based on the field’s name
or id
attributes.
This is how browsers did it before the autocomplete
attribute came along.
So for maximum support use both the name
and autocomplete
attributes.
But if you want Chrome (and other browsers) to stop autofilling fields then you need to use a name
, id
and autocomplete
value that the browser doesn’t recognise.
<input
name="xyz123"
id="xyz123"
autocomplete="xyz123"
>
As a side note: Chrome will correctly not autofill a ‘create password’ field if you use these attributes:
<input
name="new-password"
id="new-password"
autocomplete="new-password"
>
As above, this could have still been achieved with a random value, but it’s nice to have a readable field name.
Maybe a prefix of new-
should become the readable convention for browsers to ignore autofill?
UX that actually works in 3 minutes or less
Join 4000 UXers in my weekly newsletter. Every Sunday morning, you'll get 1 design tip that shuns ‘best practice’ and actually works. Mostly about forms but not always.