The autocomplete attribute
The autocomplete
attribute disables automatic form completion.
Automatic autofill is when the browser suggests to substitute in the field the data that has already been entered in this field earlier. This may not always be convenient, since, for example, the browser can suggest your login or password to an intruder, etc. For fields in which secret information is entered, autofill should be disabled.
The autocomplete
attribute can be used not only to hide secret information. For example, you can disable autocomplete in test answers. This is necessary so that when you retake the test, the browser does not prompt the answers (the whole interest of the tests is lost).
It can be used as an attribute without a value, or one of the values can be specified.
Values
Meaning | Description |
---|---|
on |
Autofill is enabled (this is the default value). |
off |
Autofill is disabled. |
Example
Let's enable autofill in input
. For example, enter the word "autofill" and click the send button (this is necessary, since the browser only remembers sent words). After that, go back to the example and enter the letter "a" - the browser will prompt you for the word "autofill" and you can select it without entering the whole word:
<form action="">
<input type="text" autocomplete="on" name="test">
<input type="submit">
</form>
:
Example
Now let's turn off autofill. Do the same manipulations as in the previous example, but no hints will appear:
<form action="">
<input type="text" autocomplete="off" name="test">
<input type="submit">
</form>
:
See also
-
tag
datalist
,
which creates autocomplete based on your list