What is the difference between input type password - autocomplete "on" and "current-password" in html form?

Viewed 236

Can anyone explain the difference between "on" and "current password" in html password autocomplete attribute.

2 Answers

See the MDN description of the autocomplete attribute.

on means that browser should look at the context and guess what type of data the field should be auto-completed with.

current-password means it should be autocompleted with the user's current password for the site.

Compare that to new-password:

A new password. When creating a new account or changing passwords, this should be used for an "Enter your new password" or "Confirm new password" field, as opposed to a general "Enter your current password" field that might be present. This may be used by the browser both to avoid accidentally filling in an existing password and to offer assistance in creating a secure password (see also Preventing autofilling with autocomplete="new-password").

<h1> Change your password </h1>

<label> 
    Current password 
    <input type="password" name="old" autocomplete="current-password">
</label>

<label> 
    New password 
    <input type="password" name="new" autocomplete="new-password">
</label>


<label> 
    Confirm your new password 
    <input type="password" name="repeat" autocomplete="new-password">
</label>

</form

… or some of the non-password options.

Here is an answer to your question

"new-password" A new password. When creating a new account or changing passwords, this should be used for an "Enter your new password" or "Confirm new password" field, as opposed to a general "Enter your current password" field that might be present. This may be used by the browser both to avoid accidentally filling in an existing password and to offer assistance in creating a secure password (see also Preventing autofilling with autocomplete="new-password").

"on" The browser is allowed to automatically complete the input. No guidance is provided as to the type of data expected in the field, so the browser may use its own judgement.

Source: mozilla.org

Related