Form autocomplete attribute
Definition and Usage
autocomplete
Set or return the value of the autocomplete attribute in the form.
After enabling auto-complete, the browser will automatically complete values based on the user's previous inputs.
Tip: You can set the form to "enable" auto-complete and set the specific input field to "disable", and vice versa.
Tip: In some browsers, you may need to enable the auto-complete feature to work properly (check the "Preferences" menu in the browser menu).
See also:
HTML Reference Manual:HTML <form> autocomplete 属性
Example
Example 1
Set auto-complete to off:
document.getElementById("myForm").autocomplete = "off";
Example 2
Return the status of auto-complete:
var x = document.getElementById("myForm").autocomplete;
Syntax
Return autocomplete attribute:
formObject.autocomplete
Set up autocomplete attribute:
formObject.autocomplete = on|off
属性值
值 | 描述 |
---|---|
on | 默认。浏览器将根据用户之前输入的值自动完成值。 |
off | 用户每次使用都必须在每个字段中输入值。浏览器不会自动完成条目。 |
技术细节
返回值: | 字符串值,表示自动完成的状态。 |
---|
浏览器支持
表中的数字注明了首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |