autocomplete="off" not working for Google Chrome

11,946

Solution 1

Since I have been having this very same issue and it seems all "alternatives" stopped working as the browsers have been getting recent updates, I came across a "dirty" solution that baffled me completely.

If we go on each field we want to disable the autocomplete feature and set its autocomplete attribute to an invalid value (only "off" and "on" are valid), the browser will stop trying to autofill those fields because of that.

Surprised? So was I!

Example:

<input type="text" autocomplete="stopdoingthat" />

And apparently it works. Stupid, I know, but it's a "dirty" one that actually works for now.

Solution 2

Recent Version of Google Chrome are forcing Autofill irrespective of the Autocomplete=off . You are going to need little bit of hack here. Some of the previous hacks don't work anymore (34+ versions)

I have tested following code on Google Chrome v36.

It removes "name" and "id" attributes from elements and assigns them back after 1ms. This works perfectly in my case.

Put this code in document ready.

 $(document).ready(function () {

$('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {

                var input = this;
                var name = $(input).attr('name');
                var id = $(input).attr('id');

                $(input).removeAttr('name');
                $(input).removeAttr('id');

                setTimeout(function () {
                    $(input).attr('name', name);
                    $(input).attr('id', id);
                }, 1);
            });
         });;

Solution 3

For Asp.Net TextBox adding TextMode="Search" and AutoCompleteType="Disabled" worked for me

<asp:TextBox runat="server" ID="txtAddress" CssClass="form-control" TextMode="Search" AutoCompleteType="Disabled"></asp:TextBox>

and i tested this in both Edge (Version 89.0.774.48) and Chrome (Version 88.0.4324.190 )

Share:
11,946
Sangram Nandkhile
Author by

Sangram Nandkhile

SOreadytohelp Full Stack .NET developer, Melbourne, Australia Linkedin: https://www.linkedin.com/in/sangram-nandkhile/

Updated on June 05, 2022

Comments

  • Sangram Nandkhile
    Sangram Nandkhile almost 2 years

    This question has been asked Several times in the past but unfortunately there's no way i could disable autofill for Google Chrome (v.36.0.1985.125 m)

    I have already Tried

    "AutoComplete=Off" not working on Google Chrome Browser

    How do I stop Chrome from pre-populating input boxes?

    how to disable google chrome suggestion list when using twitter bootstrap typeahead?

    Code tested so far

    <form autocomplete="off">
    
    <asp:textbox autocomplete="off">
    
    AutoCompleteType="Disabled"
    

    But I still get autofiled data on my login page. Passwords are populated even if Textbox Ids are changed.

  • dlchambers
    dlchambers over 5 years
    Didn't work for me, Chrome Version 69.0.3497.100 (Official Build) (64-bit)
  • Worth Lutz
    Worth Lutz over 5 years
    This worked for me to stop autofill on chrome where nothing else I found worked. Thanks!!
  • McGuireV10
    McGuireV10 over 4 years
    See comment 164 for an explanation about why this works (and why Google is, again, taking the annoying "We know better than you" position ... feels like the IE days, doesn't it?) chromium bug 468153 comment 164
  • Admin
    Admin over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.