个人信息字段必须说明其收集的内容

要求用户填写本人信息的字段,例如姓名、电子邮件、电话、地址或密码,应通过 autocomplete 属性声明其用途,这样浏览器和辅助工具才能识别并自动填写它们。

Readabler 检查

规则 IDrdb-autocomplete-missing
影响程度中等
成功标准 1.3.5 识别输入目的 · AA
标准WCAG 2.1 · WCAG 2.2 · EN 301 549
Readabler 修复 自动修复

示例

修复前
<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone">
<label for="zip">ZIP code</label>
<input type="text" id="zip" name="zip">

浏览器可能猜错,或者不提供已保存的数据,用户只能全部手动输入。

修复后
<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone" autocomplete="tel">
<label for="zip">ZIP code</label>
<input type="text" id="zip" name="zip" autocomplete="postal-code">

浏览器一步填好已保存的电话号码和邮政编码。

为什么重要

WCAG 1.3.5 要求收集用户信息的字段在代码中标明其用途。浏览器会根据字段名称进行猜测,但在很多表单上都会猜错,尤其是其他语言的表单,或使用 field_3 这类通用名称的字段。

有记忆或认知障碍的人可能记不住自己的邮政编码或电话号码。有运动障碍、手部震颤或重复性劳损的人觉得打字又慢又累,阅读障碍用户在输入电子邮件地址这类长字符串时更容易打错字。可靠的自动填充能省去大部分功夫。密码管理器也依靠 current-password 和 new-password 来正确保存和推荐密码。更快捷的表单对所有人都有帮助,通常还能提高结账和注册的完成率。

如何修复

添加与字段要求内容相符的标记。最常用的标记:

<input type="text" name="fname" autocomplete="given-name">
<input type="text" name="lname" autocomplete="family-name">
<input type="email" name="email" autocomplete="email">
<input type="tel" name="mobile" autocomplete="tel">
<input type="text" name="company" autocomplete="organization">
<input type="text" name="city" autocomplete="address-level2">

登录和注册表单。 告诉密码管理器哪个是哪个密码:

<input type="text" name="user" autocomplete="username">
<input type="password" name="pass" autocomplete="current-password">
<input type="password" name="new_pass" autocomplete="new-password">

分开的收货地址和账单地址。 为标记添加前缀:

<input type="text" name="bill_zip" autocomplete="billing postal-code">

关于他人的字段,例如礼物收件人的姓名,与用户本人无关。请使用 autocomplete="off" 或中性标记,以免自动填充插入购买者本人的信息。

autocomplete="on" 不算数:它没有说明字段收集的是什么。

检查清单

  1. 为每个填写用户本人信息的字段添加 autocomplete。
  2. 密码字段使用 current-password 和 new-password。
  3. 在拆分的地址表单中加上 shipping 或 billing 前缀。
  4. 关于他人的字段使用 off。

检查原理

检查会查看可见、已启用且可编辑、没有 autocomplete 值或值为 on 的 <input> 字段。它根据类型(email、tel、password),或根据字段的 name、id、标签、占位文字和 aria-label(支持多种语言)推断用途,并跳过搜索、URL 和优惠券字段。如果识别出电子邮件、电话、姓名或邮政编码等用途,则检查不通过。无法识别的字段需要人工审核。

参考资料

更新于 2026年10月27日