Disable input autofill
-
When writing a Form form style, it is troublesome or even impossible to modify the input style after autofill, and there are some scenarios that do not need autofill.
-
The
type
browsername
matches according to the and of the form control when saving the data. -
The commonly used ones are
type
forpassword
,name
foremal
,username
,password
,telephone
etc., even if not setname
. -
The browser will match the previously saved form space when the form is loaded, and then automatically fill it with the information saved on the client side. Additional data may be filled into adjacent form controls.
-
Autofill can be turned off by setting
autocomplete
to .off
-
input
autocomplete
indicates whether the value of this control can be automatically filled by the browser, settingoff
it to means that the user must manually fill in the value, or the page provides its own auto-completion method. Browsers do not autofill this field. . -
However, the browser still displays the autofill hint (option box) when the form control gets focus.
-
And in the actual situation
type
,password
even if the form control for is setautocomplete="off"
, it can't effectively prohibit automatic filling (most of them don't work). -
Fortunately
autocomplete
setting tonew-password
successfully disables this, which represents a new password (such as used when creating an account or changing a password). -
The reference is 163 mailbox:
-
And its compatibility is also good:
Program Summary
-
If you want to disable the autofill function of the form control, you can
autocomplete="new-password"
add . If there are more than one in a formtype="password"
, you only need to set this attribute to one of them (no matter which one) to disable them all. -
Setting can
new-password
also prevent the browser from popping up autofill prompts, includingtype="password"
controls other than .