如何在主要浏览器中禁用特定输入(或表单字段)的自动完成?


当前回答

只需在输入中自动完成=“off”list=“autocompleteOff”,即可完成IE/Edge的工作!对于chrome,添加autocomplete=“新密码”

其他回答

我使用此TextMode=“password”autocomplete=“new password”,并在aspx txtPassword.Attributes.Add(“value”,“”)中加载页面;

了解Firefox(我认为只有Firefox)使用了一个名为ismxfilld的值,该值基本上强制自动完成,这一点很重要。

ismxfilld=“0”表示关闭

or

ismxfilld=“1”表示开启

这将解决此问题

autocomplete="new-password"

为了解决这个问题,我使用了一些CSS技巧和以下工作。

input {
    text-security:disc;
    -webkit-text-security:disc;
    -mox-text-security:disc;
}

请阅读本文了解更多详情。

在尝试了所有解决方案之后(有些解决方案部分奏效,禁用自动填充但不自动完成,有些根本不奏效),我找到了截至2020年的最佳解决方案,将type=“search”和autocomplete=“off”添加到输入元素中。这样地:

<input type="search" /> or <input type="search" autocomplete="off" />

还要确保表单元素具有autocomplete=“off”。这非常有效,并禁用自动完成和自动填充。

此外,如果您使用type=“email”或任何其他文本类型,则需要添加autocomplete=“new email”,这将完全禁用两者。type=“password”也是如此。只需将“new-”前缀与类型一起添加到自动完成中即可。这样地:

<input type="email" autocomplete="new-email" />
<input type="password" autocomplete="new-password" />