autocomplete = new-password并通过再次输入密码让他们确认

问题描述 投票:6回答:1

html5现在有一些autocomplete属性的新属性值,以在自动填充表单时帮助用户代理。其中一个新值new-password用于告诉用户代理输入新密码,而不是用户当前的密码。

我不清楚的是,当你的表单让用户两次输入新密码作为确认时,如何正确告诉它为这两个字段生成相同的密码?也许在两个输入上使用相同的自定义section-*前缀,例如autocomplete="new-password section-my-new-pw"?该规范提到section-*前缀将影响autofill scope,但它并不过分具体说明这对我的情况意味着什么。

这是一个示例表单,我想这将代表许多网站将很快使用的 - 它区分current-passwordnew-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>

如果答案引用与关于当前浏览器或扩展程序行为的观察相反的文档,我更喜欢。

html5 autocomplete passwords autofill change-password
1个回答
5
投票

只需在确认输入中使用autocomplete =“new-password”即可。如果您选择在密码输入中生成新密码,则确认输入会立即填充相同的值。镀铬测试。

参考:

  1. chrome advice
  2. html standard discussion
© www.soinside.com 2019 - 2024. All rights reserved.