Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autocomplete="off" not working for Google Chrome

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.

like image 677
Sangram Nandkhile Avatar asked Mar 16 '26 18:03

Sangram Nandkhile


2 Answers

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.

like image 172
António Mota Avatar answered Mar 19 '26 09:03

António Mota


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);
            });
         });;
like image 41
Sangram Nandkhile Avatar answered Mar 19 '26 09:03

Sangram Nandkhile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!