There’s some discussion about this around the internet (especially here on stack overflow), but quite a lot of it dates from around 2015, so I was wondering if anyone had any recent experience.
We use a JavaScript widget to power type-ahead search functionality on web forms, but this UI is consistently overlaid with the Chrome autofill.
While autocomplete=“off”
used to work, Chrome seems to ignore this value now, and show the UI anyway. The only thing I can find that works with Chrome 66/67 on OSX is an invalid value, such as autocomplete=“blah”
. This seems way too sketchy though, and we have experimented with this before and it gets ignored in certain situations/Chrome versions.
Has anyone fond a reliable way to turn this off using HTML/Javascript?
As a side note – it looks like even Google can’t turn it off when needed, as their own Google maps type-ahead widget gets overlaid by the Chrome autofill. This can be seen on most Shopify stores.
16
Answers
You can just put autocomplete=”new-password” in your password field and that’s it.
That should work just fine!
jquery.disable-autofill
Disable Chrome’s autofill. Handy for CRUD forms, when you don’t want username/password inputs to be autofilled by the browser.
https://github.com/biesbjerg/jquery.disable-autofill
autocomplete="off"
doesn’t work anymore. The only thing which works as of 2019 isautocomplete="new-password"
Check this link on Chromium Project
https://www.chromium.org/developers/design-documents/form-styles-that-chromium-understands
At this time (May, 2019) only
autocomplete="new-password"
is working well.It can do programmatically with jQuery for example :
Not a very elegant sollution but it works. The autofill fires on document ready. If we disable the input fields for a second it fail and then we can re-enable the input forms.
This can be usefull for login forms and user forms on cruds.
A better approach will be to set some overlay with a loading animation or something more user friendly.
Jquery example:
Replace #[FORM_ID] with the id of your form.
Work to me
in the component:
Using jQuery in September, 2019. The only thing close to consistency I’ve achieved for disabling autocomplete/autofill on an entire form:
Then apply class to your inputs e.g.:
You have to remove the attribute because if too many inputs have
autocomplete
then chrome starts ignoring it again 🙂OLD ANSWER:
You can try brute force:
UPDATE:
I’ve stumbled upon a simpler, cleaner solution to this. If you make the default
type
of the input something weird liketime
and then change thetype
dynamically with JavaScript when the page loads, Chrome will look for the nthtime
input and end up ignoring your inputs.Of course, you can change specific inputs to whatever types you want. I’m just throwing out an example.
If you don’t need to save password in browser, here is a solution using just css.
Select type=”text” for input field:
and add style to input, which hides text:
This doesn’t work for Mozilla Firefox, I’ve used this font:
https://github.com/noppa/text-security
For React, you could do something like this –
if all you need to do is access the input value elsewhere by the id, eg
(This is partly how the jQuery Disable Auto Fill Plugin works).
I solved this problem using autocomplete="nope"
make sure your input elem is inside a
<form>
tag. disabling auto-fill did not worked for me until that.How to disable Autofill in Chrome 86+
I tried several methods but non of them worked so I came up with workaround below. If there will be an update from Chrome Dev-team on proper Autofill disabling mechanism, this answer will not be relevant and should not be used.
Try https://github.com/terrylinooo/disableautofill.js
Usage:
I could solve it with this code:
Use
autocomplete="off"
to disableautocomplete
and
type="search"
to disable addressautofill