【问题标题】:Autocomplete off is not working in html with chrome自动完成关闭在带有 chrome 的 html 中不起作用
【发布时间】:2014-02-17 06:17:09
【问题描述】:

有时在我的 Web 应用程序中,即使我声明 form autocompleteoff 有时它也不起作用,它 autocomplete 我输入了我的输入。

谁能知道如何解决这种问题。顺便说一下,我用的是chrome。

我的代码示例:有时它的 autocompleting 我的输入即使我已经声明关闭了..

<form autocomplete="off" method="post">
    <input autocomplete="off" type="text" name="name">
    <input autocomplete="off" type="text" name="age">
    <input type="submit" >
</form>

【问题讨论】:

标签: html google-chrome forms


【解决方案1】:
<form autocomplete="off" method="post">
<input autocomplete="off" type="text" name="name"  value="">
<input autocomplete="off" type="text" name="age"  value="">
<input type="submit" >
</form>

【讨论】:

    【解决方案2】:

    解决方案很简单,在所有浏览器中都能完美运行。

    1. 向表单字段(姓名、年龄等)添加 disabled 和 autocomplete="off" 属性

      <form method="post">
        <input disabled="disabled" autocomplete="off" type="text" class="name" name="name">
        <input disabled="disabled" autocomplete="off" type="text" class="age" name="age">
        <input type="submit" >
      </form>
      
    2. 在页面加载时,几毫秒后启用字段。

    使用下面的 JS 代码

    function getRidOffAutocomplete(){               
        var timer = window.setTimeout( function(){
            $('.name, .age').prop('disabled',false);
                clearTimeout(timer);
            }, 800);
        }
    
    // Invoke the function
    getRidOffAutocomplete();
    

    【讨论】:

      【解决方案3】:

      这不是错误 - Chrome 不再支持 autocomplete。这是他们的开发人员的设计决定,您应该为它设计而不是试图解决它。见我的answer to this very similar question

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-29
        • 2015-04-01
        • 2010-09-19
        • 1970-01-01
        • 2016-01-11
        • 2013-10-27
        • 1970-01-01
        相关资源
        最近更新 更多