我遇到了chrome自动填充行为的几个形式的问题。

表单中的字段都有非常常见和准确的名称,例如“email”、“name”或“password”,并且它们还设置了autocomplete=“off”。

自动完成标志已经成功禁用了自动完成行为,当你开始输入时,会出现一个下拉的值,但没有改变Chrome自动填充字段的值。

这种行为是可以的,除了chrome填充输入不正确,例如填充电话输入与电子邮件地址。客户抱怨过这个问题,所以它被证实在很多情况下都发生了,而不是我在我的机器上本地操作的某种结果。

目前我能想到的唯一解决方案是动态生成自定义输入名称,然后在后端提取值,但这似乎是一种相当笨拙的解决这个问题的方法。是否有任何标签或怪癖,改变自动填充行为,可以用来解决这个问题?


当前回答

我也遇到过同样的问题。这里是禁用自动填充用户名和密码的Chrome解决方案(仅在Chrome上测试)

    <!-- Just add this hidden field before password as a charmed solution to prevent auto-fill of browser on remembered password -->
    <input type="tel" hidden />
    <input type="password" ng-minlength="8" ng-maxlength="30" ng-model="user.password" name="password" class="form-control" required placeholder="Input password">

其他回答

这里有两个部分。Chrome和其他浏览器会记住之前输入的字段名的值,并基于此为用户提供一个自动完成列表(值得注意的是,密码类型的输入永远不会以这种方式记住,原因相当明显)。你可以添加autocomplete="off"来防止这种情况发生在你的电子邮件字段上。

但是,您还可以使用密码填充器。大多数浏览器都有自己的内置实现,也有许多第三方实用程序提供此功能。这个,你停不下来。这是用户自己选择保存该信息以便稍后自动填写,完全超出了应用程序的范围和影响范围。

尝试在值中添加一个空格:

<input type="email" name="email" value="&nbsp;">
<input type="password" name="password" value="&nbsp;">

chrome 54.0.2840.59

在Chromium 53.0.2785.92(64位)上,以下工作

<div style="visibility:hidden">
    <input type="text" name="fake_username_remembered">
    <input type="password" name="fake_password_remembered">
</div>

显示:none不工作

What I have done it to change the input type="text" to a multi line input ie. overflow-x:hidden; overflow-y:hidden; vertical-align:middle; resize: none; A quick explanation of the code: The overflow-x and -y hidden wil disable the scroll buttons on the right of the textarea box. The vertial algin will align the lable vertical middle with the text area and the resize: none will disable the resize grabber at the bottom right of the textarea. In essance it means that your textarea will appear like a textbox, but with chrome autofill off.

不同的解决方案,基于webkit。如前所述,任何时候Chrome发现一个密码字段,它自动完成电子邮件。AFAIK,这与autocomplete = [whatever]无关。

为了避免这种情况,将输入类型更改为文本,并以任何您想要的形式应用webkit安全字体。

.secure-font{
-webkit-text-security:disc;}

<input type ="text" class="secure-font">

从我所看到的,这至少是安全的输入类型=密码,它的复制和粘贴安全。然而,它是脆弱的,通过删除将删除星号的样式,当然input type = password可以很容易地在控制台中更改为input type = text,以显示任何自动填充的密码,所以它是非常相同的。