Mauro Vanetti
Mauro Vanetti

Reputation: 512

Chrome stores the new password but does not link it to the current username: how can I fix it?

In a website I have created a page to change the user's password to a new one. Obviously, the current username does not need to be typed again by the user therefore there is no input field for the username.

Of course, Chrome understands that this is a new password and suggests to save it but it cannot find out what the username is.

I tried like this:

<input id="psw" name="psw" type="password" autocomplete="new-password">
<input id="psw_confirm" name="psw_confirm" type="password" autocomplete="new-password">

and like this:

<input id="usr" name="usr" type="hidden" value="username" autocomplete="username">
<input id="psw" name="psw" type="password" autocomplete="new-password">
<input id="psw_confirm" name="psw_confirm" type="password" autocomplete="new-password">

to no avail.

It reads "Update the password?"

How should I indicate the current username in a way the browser can understand properly?

Upvotes: 4

Views: 896

Answers (1)

Darkseal
Darkseal

Reputation: 9564

Unfortunately, I don't think that <input type="hidden" /> will trigger Chrome password manager, as it's designed to catch type='text' inputs only. That said, you should be fine using a standard text input with the display:none css property set:

<input id="usr" name="usr" type="text" 
    value="username" style="display: none;" />

I also think that your scenario (password change) is not an ideal one for the autocompletion feature, therefore I would also switch that attribute off (it won't affect the Chrome password manager).

Here's a jsfiddle with a working sample.

Upvotes: 6

Related Questions