Chrome 存储新密码但不 link 当前用户名:我该如何解决?

Chrome stores the new password but does not link it to the current username: how can I fix it?

在一个网站中,我创建了一个页面来将用户密码更改为新密码。显然,用户不需要再次输入当前用户名,因此没有用户名输入字段。

当然,Chrome知道这是一个新密码并建议保存它,但它找不到用户名是什么。

我这样试过:

<input id="psw" name="psw" type="password" autocomplete="new-password">
<input id="psw_confirm" name="psw_confirm" type="password" autocomplete="new-password">

像这样:

<input id="usr" name="usr" type="hidden" value="username" autocomplete="username">
<input id="psw" name="psw" type="password" autocomplete="new-password">
<input id="psw_confirm" name="psw_confirm" type="password" autocomplete="new-password">

无果。

我应该如何以浏览器可以正确理解的方式指示当前用户名?

不幸的是,我认为 <input type="hidden" /> 不会触发 Chrome 密码管理器,因为它旨在仅捕获 type='text' 输入。也就是说,使用 display:none css 属性 集的标准文本输入应该没问题:

<input id="usr" name="usr" type="text" 
    value="username" style="display: none;" />

我还认为您的方案(密码更改)不是 autocompletion 功能的理想方案,因此我也会切换该属性 off(它不会影响 Chrome密码管理器)。

Here's a jsfiddle 有工作样本。