In my app I have a "change password" form which requires a user to enter their current password and their new password (twice).
The purpose of entering the current password is a security measure, e.g. if a user steps away from their desk, it prevents someone else from changing their password and gaining control of their account.
For this reason, I absolutely do not want this field to be autocompleted. However, if I don't specify an autocomplete
attribute, I get the following warning in Chrome's dev console
[DOM] Input elements should have autocomplete attributes (suggested: "current-password"): (More info: https://www.chromium.org/developers/design-documents/create-amazing-password-forms/) <input id="current-password" type="password">
If I add an attribute autocomplete="current-password"
the warning no longer appears, but the field is filled automatically with the user's current password, which defeats the very purpose of this field.
How can I prevent this field from being filled automatically without getting a warning in the Chrome console?
CodePudding user response:
You could use the value off in the autocomplete attribute.
For example: autocomplete="off"
Read more about it on MDN Web Docs.