0

I'm using the following ASP.NET code to make my input box not to use autocomplete:

<asp:TextBox ID="TextBoxID" AutoCompleteType="Disabled" runat="server"></asp:TextBox>

It works with Microsoft's own IE, but Google Chrome still allows autocomplete on it. So what am I doing wrong?

c00000fd
  • 20,994
  • 29
  • 177
  • 400

3 Answers3

1

For Chrome the autocomplete="off" specification has to be placed on the form tag.

roydukkey
  • 3,149
  • 2
  • 27
  • 43
1

Recent Version of Google Chrome forces Autofill irrespective of the Autocomplete=off.Some of the previous hacks don't work anymore (34+ versions)

I have tested following code on Google Chrome v36.

Solution 1: Putting 2 lines of code under under <form ..> tag does the trick.

<form id="form1" runat="server" >
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>

...

Read more

Solution 2: It removes "name" and "id" attributes from elements and assigns them back after 1ms. Put this in document get ready.

$('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);
            });
Community
  • 1
  • 1
Sangram Nandkhile
  • 17,634
  • 19
  • 82
  • 116
0

Placing autocomplete=off in the form tag does not work anymore. Google ignores it.

I have solved the issue by renaming my textboxes. Do not use in the name anything that google can get hint to autocomplete it like (name,address,postalcode,etc..). I have changed txtName to txtN and autcomplete stopped.

If this does not work, place autocomplete="new-name" directly in the property of the textbox not on the form.

<asp:TextBox autocomplete="new-name" ID="txtName"  runat="server"></asp:TextBox>