Recently in one of our apps we had a form where the autocomplete needed to be turned off. Great this will be easy, set the autocomplete attribute for the form or input to “off” and we’re good to go.
<form autocomplete="off"> <input autocomplete="off">
However, this was not working on Chrome. After a little research, we found Chrome actually ignores autofill="off” by design. This presented a problem as we could not have autofill on a specific input.
The most popular solution on Stack Overflow is to add a hidden field above the field you would like to remove autocomplete from that will basically grab that autofill value before it can hit the real input. For example, having a hidden field above the password field.
<input style="display:none" type="password" name="fakepasswordremembered"/>
Though will produce the result we're looking for, it's really more of a work around than a solution. A better way to solve this problem is to use a semantic name for the autocomplete attribute.
<input type="password" name="password" autocomplete="user-password">
Now when Chrome attempts to autocomplete the field it will not auto-fill this field with a password.
Here’s some more information on the autofill attribute that you may helpful: