Input Text autocomplete Attribute

Definition and Usage

autocomplete Set the attribute or return the value of the autocomplete attribute in the text field.

After enabling autocomplete, the browser will automatically complete values based on the user's previous input.

Tip:In some browsers, you may need to enable the autocomplete feature to work properly (check under "Preferences" in the browser menu).

See also:

HTML Reference Manual:HTML <input> autocomplete 属性

Example

Example 1

Set the autocomplete of the text field to off:

document.getElementById("myText").autocomplete = "off";

Try it yourself

Example 2

Return the autocomplete status:

var x = document.getElementById("myText").autocomplete;

Try it yourself

Syntax

Return the autocomplete attribute:

textObject.autocomplete

Set the autocomplete attribute:

textObject.autocomplete = "on|off"

属性值

描述
on 默认。浏览器将根据用户之前输入的值自动完成值。
off 用户每次使用都必须在每个文本字段中输入值。浏览器不会自动完成条目。

技术细节

返回值: 字符串值,表示自动完成的状态。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持