Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML autocomplete 属性


定义和用法

The autocomplete 属性指定表单或输入字段是否应启用自动完成功能。

自动完成允许浏览器预测值。当用户开始在字段中输入时,浏览器应根据之前输入的值显示选项以填写字段。

提示:可以为表单启用自动完成功能,而为特定输入字段禁用自动完成功能,反之亦然。

注意:The autocomplete 属性与以下 <input> 类型一起使用:文本、搜索、URL、电话、电子邮件、密码、日期选择器、范围和颜色。


适用于

The autocomplete 属性可以在以下元素上使用

元素 属性
<form> autocomplete
<input> autocomplete

示例

表单示例

启用自动完成功能的表单

<form action="/action_page.php" method="get" autocomplete="on">
  姓氏:<input type="text" name="fname"><br>
  电子邮件: <input type="email" name="email"><br>
  <input type="submit">
</form>
自己试一试 »

输入示例

一个启用自动完成功能的 HTML 表单(但一个输入字段已禁用自动完成功能)

<form action="/action_page.php" autocomplete="on">
  姓氏:<input type="text" name="fname"><br>
  姓氏: <input type="text" name="lname"><br>
  电子邮件: <input type="email" name="email" autocomplete="off"><br>
  <input type="submit">
</form>
自己试一试 »

浏览器支持

The autocomplete 属性对每个元素具有以下浏览器支持

元素
form 4.0 5.2 15.0
input 17.0 5.0 4.0 5.2 9.6

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.