autocomplete = off不在chrome中工作

Arc*_*hit 6 html google-chrome

我们正在开发一个Web应用程序,其中有一个付款页面.

我们有两个文本框,一个用于信用卡号,第二个用于验证码,它键入="密码".

现在的问题是,当google-chrome加载页面时,它发现type ="Password"它加载在信用卡文本框中保存电子邮件ID,在验证码中保存密码.

现在尝试解决这个问题我尝试了类似下面的内容.

<form autocomplete="off">

<asp:textbox autocomplete="off">
Run Code Online (Sandbox Code Playgroud)

以上尝试对我不起作用.我正在谷歌搜索它,但幸运的是,这对我不起作用.

Dar*_*ows 15

Chrome现在似乎忽略了autocomplete ="off",除非它<form autocomplete="off">自v34以来就在标签上.

你不能通过创建一个隐藏的输入作弊.自动完成功能将获得第一个输入文本以填充数据.

方法1:

<form id="" method="post" action="" autocomplete="off">
    <input type="text" style="display:none" />
    <input type="password" style="display:none">
    <asp:textbox autocomplete="off">
</form>
Run Code Online (Sandbox Code Playgroud)

所以把它放在你的文本框之前.

<input type="text" style="display:none" />
Run Code Online (Sandbox Code Playgroud)

方法2:

更改

autocomplete="off" 
Run Code Online (Sandbox Code Playgroud)

autocomplete="false" 
Run Code Online (Sandbox Code Playgroud)

方法3: 浏览器通过只读模式自动填充.

 <input type="password" readonly onfocus="this.removeAttribute('readonly');"/>
Run Code Online (Sandbox Code Playgroud)

方法4:

用于用户名密码组合.Chrome启发式查找模式.

<input type="text" onfocus="this.type='password'">
Run Code Online (Sandbox Code Playgroud)

方法5: jQuery

if ($.browser.webkit) {
    $('input[name="password"]').attr('autocomplete', 'off');
    $('input[name="email"]').attr('autocomplete', 'off');
}
Run Code Online (Sandbox Code Playgroud)

  • 方法 3 似乎是跨浏览器最可靠、最标准化的方法 (2认同)

Lai*_*acy 6

这是唯一对我来说适用于自动完成和 Chrome 的自动填充的解决方案:它在调用后也有效new this.props.google.maps.places.Autocomplete

  1. 在表单标签上添加 autocomplete="off"。

  2. 直接在表单内的输入上设置 autocomplete="none" 并再次将属性设置为焦点。

     <form autocomplete="off">
         <input type="text" autocomplete="none" onfocus="this.setAttribute('autocomplete', 'none');"/>
     </form>
    
    Run Code Online (Sandbox Code Playgroud)