autocomplete=new-password 并让他们通过再次输入密码进行确认
autocomplete=new-password and making them confirm it via entering the password again
html5 现在为 autocomplete
属性添加了一些新的属性值,以在自动填充表单时协助用户代理。其中一个新值 new-password
用于告诉用户代理输入 new 密码,而不是用户的 current密码。
我不清楚的是,当您的表单让用户输入两次新密码作为确认时,如何正确地告诉它为两个字段生成相同的密码? 也许通过在两个输入上使用相同的自定义 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>
我更喜欢答案参考文档而不是关于当前浏览器或扩展程序行为的观察。
只需在确认输入处使用自动完成="new-password"。如果您选择在密码输入中生成新密码,确认输入会立即填充相同的值。在 chrome.
中测试
参考:
html5 现在为 autocomplete
属性添加了一些新的属性值,以在自动填充表单时协助用户代理。其中一个新值 new-password
用于告诉用户代理输入 new 密码,而不是用户的 current密码。
我不清楚的是,当您的表单让用户输入两次新密码作为确认时,如何正确地告诉它为两个字段生成相同的密码? 也许通过在两个输入上使用相同的自定义 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>
我更喜欢答案参考文档而不是关于当前浏览器或扩展程序行为的观察。
只需在确认输入处使用自动完成="new-password"。如果您选择在密码输入中生成新密码,确认输入会立即填充相同的值。在 chrome.
中测试参考: