Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete = "new password" not working and "use password for" dropdown list still shown

I created a login form with input text for username and input of type password for userpass using visual studio 2010. I have the latest chrome Version 59.0.3071.115 (Official Build) (32-bit). Below is my code:

<form id="form1" autocomplete="off" runat="server">
    <input id="Text1" type="text" name="text" runat="server" autocomplete="off" />
    <input id="Password1" type="password" name="password" runat="server" autocomplete="off" />
</form>

the problem is that only on chrome if I click on any of those inputs a dropdown list appears with some suggestions of my saved pass on the browser. I want to disable this option so I searched and found this solution:

<input id="Password1" type="password" name="password" runat="server" 
         autocomplete="new-password" />

New password will disable autofill because it will take into consideration that each time user will enter a new pass, so no need for suggestions. But this is not happening here... actually when I added new password for input pass, the dropdown list disappeared for input text but still shown for input pass... Weird ... So how can I disable it for both inputs? Thanks

like image 825
AlessHo Avatar asked Jul 27 '17 08:07

AlessHo


People also ask

How do I use autocomplete for new password?

Use autocomplete="new-password" and id="new-password" for the password input in a sign-up form, and for the new password in a reset-password form. Use autocomplete="current-password" and id="current-password" for a sign-in password input.

How do I turn off autocomplete on password field?

Preventing autofilling with autocomplete="new-password" If you are defining a user management page where a user can specify a new password for another person, and therefore you want to prevent autofilling of password fields, you can use autocomplete="new-password" .

How do I turn off autocomplete in HTML?

Use the <input> tag with autocomplete attribute. Set the autocomplete attribute to value “off”.


1 Answers

You can prevent Chrome from suggesting by adding two hidden fake fields as well as adding the autocomplete="off" to the form and autocomplete="none" to the main inputs.

Here's a working sample:

<form id="form1" autocomplete="off" runat="server">

<input style="display:none" type="text" name="fakeusername"/>
<input style="display:none" type="password" name="fakepassword"/>

<input id="Text1" type="text" name="text" runat="server" autocomplete="none" /> 
<input id="Password1" type="password" name="password" runat="server" autocomplete="none" />

<input id="bb" type="submit" name="submit" />

</form>

Jsfiddle: https://jsfiddle.net/wb20t08g/3/

NOTE: You need to delete google chrome suggestions that have been saved there from before. (Ctrl + Shift + del). But after that if you click on submit, Chrome won't show any pop-up mentioning if you want to save the password or any dropdown for suggestions.

like image 190
Sorena Avatar answered Sep 25 '22 09:09

Sorena