Chrome autofills username into random text input

Tom Regan picture Tom Regan · Feb 15, 2019 · Viewed 7.9k times · Source

This is happening on an asp.net webforms application, using Chrome Version 72.0.3626.109 (Official Build) (64-bit).

The site is password-protected. The user logs in with a username and password. After a successful login the user is redirected to the "Loan Search" page. The Loan Search page contains a handful of text inputs.

The problem is Chrome will autofill my username into one of the text inputs (see image). "tregan" is the username I entered into the login page.

enter image description here

Chrome always selects this particular text input to autofill the username ("Contact Mailing Address"). This is happening to myself and several dozen other users of our web site.

Any idea why Chrome is doing this autofill, and is there anything I can do to prevent it? I cleared my Chrome autofill cache, but that did not fix the problem.

Answer

Tom Regan picture Tom Regan · Feb 15, 2019

The answer is to add an invisible text input to the asp.net form called "username".

Several years ago we were having the same problem with a different input. The answer was to add an invisible input of type "password", as explained in this SO answer, scroll down to the phrase "It is so simple and tricky...":

Disabling Chrome Autofill

Below is the complete fix, I added these two elements inside the form element in our site's master page. Per @Jeff_Mergler's comment below, put these inputs at the top of your form tag:

<input type="text" id="username" style="width:0;height:0;visibility:hidden;position:absolute;left:0;top:0" />
<input type="password" style="width:0;height:0;visibility:hidden;position:absolute;left:0;top:0" />