Input elements should have autocomplete attributes
From Chromium Projects' Design Documents:
Autocomplete attributes help password managers to infer the purpose of a field in a form, saving them from accidentally saving or autofilling the wrong data.
You can use the autocomplete
attribute on an HTML element that needs to be managed by a password manager for automatically filling its value. The value of autocomplete
attribute depends on the field about which you want to convey more information to the password manager. Consider the following examples:
- Current password field -
autocomplete="current-password"
- New password field -
autocomplete="new-password"
- Credit card field -
autocomplete="cc-number"
Try changing
<input type="password" name="password">
to
<input type="password" name="password" autocomplete="on">
Autocomplete lets web developers specify what (if any) permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field.
It's pretty powerful.
Turning off Autocomplete
You have the below options for working with errors of the below format Input elements should have autocomplete attributes thrown by the console by modifying:
<input type="password" name="password">
- Set the
autocomplete
attribute tooff
at the<form>
or<input>
which:- Enforces browser to NOT store any data
- Disables caching form data in the session history
<input type="password" name="password" autocomplete="off">
- Another way to prevent autofilling by the browser is:
The below suggestions are browser specific
<input type="password" name="password" autocomplete="new-password"> <!-- For Mozilla-->
<!-- or -->
<input type="password" name="password" autocomplete="current-password"> <!-- For Chrome-->