【发布时间】:2018-10-15 14:35:45
【问题描述】:
html5 现在为autocomplete 属性添加了一些新属性值,以在自动填充表单时帮助用户代理。其中一个新值new-password 用于告诉用户代理输入一个新 密码,而不是用户的当前 密码。
但我不清楚的是,当您的表单让用户输入两次新密码作为确认时,如何正确地告诉它为两个字段生成相同的密码?也许通过使用两个输入都使用相同的自定义 section-* 前缀,例如 autocomplete="new-password section-my-new-pw"?规范提到section-* 前缀会影响autofill scope,但它并没有过于具体地说明这对我的情况意味着什么。
这是一个示例表单,我想它将代表许多网站将很快使用的内容 - 它区分 current-password 和 new-password,并让用户确认新密码。
<form>
<p>Username <input type="text" autocomplete="username" name="username"></p>
<p>Current Password <input type="password" autocomplete="current-password" name="current-password"></p>
<p>New Password <input type="password" autocomplete="new-password" name="new-password"></p>
<p>Confirm New Password <input type="password" autocomplete="new-password" name="confirm-new-password"></p>
</form>
我更喜欢答案参考文档而不是观察当前浏览器或扩展程序的行为。
【问题讨论】:
-
你不应该在段落中使用输入。
-
@undefined 为什么不呢?多年来,我在许多来自知名来源的例子中都看到了这种做法。即whatwg.org 和mozilla
-
我相信它已经过时了。段落通常用于文本,将它们用作容器可能会导致排版样式出现问题,尤其是间距。
<div>通常更适合容器。
标签: html autocomplete passwords autofill change-password