html5 now has some new attribute values for the autocomplete
attribute to assist user-agents when autofilling forms. One of the new values, new-password
, is used to tell the user agent to enter a new password, opposed to the user's current password.
What's not clear to me though, is how to properly tell it to generate the same password for both fields when your form makes the user enter the new password twice as a confirmation? Maybe by using the same custom section-*
prefix on both inputs, such as autocomplete="new-password section-my-new-pw"
? The spec mentions the section-*
prefix will affect the autofill scope, but it's not overly specific about what that means for my case.
Here's a sample form that I imagine will represent what many websites will soon use - it distinguishes the current-password
from the new-password
, and makes the user confirm the new password.
<form> <p>Username <input type="text" autocomplete="username" name="username"></p> <p>Current Password <input type="password" autocomplete="current-password" name="current-password"></p> <p>New Password <input type="password" autocomplete="new-password" name="new-password"></p> <p>Confirm New Password <input type="password" autocomplete="new-password" name="confirm-new-password"></p> </form>
I much prefer if answers reference a documentation opposed to observations about how current browsers or extensions behave.
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" . This is a hint, which browsers are not required to comply with.
Use autocomplete="current-password" and id="current-password" for the password input in a sign-in form, or the input for the user's old password in a change-password form. This tells the browser that you want it to use the current password that it has stored for the site.
Turn on autocompletions: From the control panel, select the search engine you want to edit. Click Search features from the menu on the left and then click the Autocomplete tab. Click on the slider to set Enable autocomplete to On.
Just use autocomplete="new-password" at the confirmation input. And if you choose to generate a new password in the password input, the confirmation input gets filled with the same value instantly. Tested in chrome.
Reference:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With