自动填充功能不适用于带有chrome的html

时间:2014-02-17 06:17:10

标签: html forms google-chrome html-form

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

任何人都可以知道如何解决这类问题。我顺便使用铬。

我的代码示例:有时我的autocompleting我的输入甚至我已经宣布关闭..

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

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分:1)

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

  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. On Page Load在几毫秒后启用字段。

  3. 使用以下JS CODE

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

答案 2 :(得分:0)

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