自动完成="新密码"无法正常工作,"使用密码"下拉列表仍然显示

H.A*_*.Al 10 html google-chrome autocomplete autofill

我创建了一个登录表单,其中包含用户名的输入文本和使用visual studio 2010输入的userpass类型密码.我有最新的chrome版本59.0.3071.115(官方版本)(32位).以下是我的代码:

<form id="form1" autocomplete="off" runat="server">
    <input id="Text1" type="text" name="text" runat="server" autocomplete="off" />
    <input id="Password1" type="password" name="password" runat="server" autocomplete="off" />
</form>
Run Code Online (Sandbox Code Playgroud)

问题是,只有在Chrome上点击任何一个输入时,才会出现一个下拉列表,其中包含我在浏览器上保存的传递的一些建议.我想禁用此选项,所以我搜索并找到了这个解决方案:

<input id="Password1" type="password" name="password" runat="server" 
         autocomplete="new-password" />
Run Code Online (Sandbox Code Playgroud)

新密码将禁用自动填充,因为每次用户输入新密码时都会考虑自动填充,因此无需提供建议.但这并没有发生在这里...实际上当我为输入传递添加新密码时,下拉列表消失了输入文本仍然显示输入传递 ...很奇怪...那么我怎样才能为两个输入禁用它?谢谢

Sor*_*ena 2

您可以通过添加两个隐藏的虚假字段以及将 添加autocomplete="off"到表单和autocomplete="none"主输入来阻止 Chrome 提出建议。

这是一个工作示例:

<form id="form1" autocomplete="off" runat="server">

<input style="display:none" type="text" name="fakeusername"/>
<input style="display:none" type="password" name="fakepassword"/>

<input id="Text1" type="text" name="text" runat="server" autocomplete="none" /> 
<input id="Password1" type="password" name="password" runat="server" autocomplete="none" />

<input id="bb" type="submit" name="submit" />

</form>
Run Code Online (Sandbox Code Playgroud)

Jsfiddle: https: //jsfiddle.net/wb20t08g/3/

注意: 您需要删除之前保存在其中的 google chrome 建议。( Ctrl++ Shift) del。但此后,如果您点击“提交”,Chrome 将不会显示任何弹出窗口,提示您是否要保存密码或任何建议下拉菜单。