Chrome ignores autocomplete=“off”

后端 未结 30 1557
礼貌的吻别
礼貌的吻别 2020-11-22 00:42

I\'ve created a web application which uses a tagbox drop down. This works great in all browsers except Chrome browser (Version 21.0.1180.89).

Despite both the

相关标签:
30条回答
  • 2020-11-22 01:08

    After the chrome v. 34, setting autocomplete="off" at <form> tag doesn`t work

    I made the changes to avoid this annoying behavior:

    1. Remove the name and the id of the password input
    2. Put a class in the input (ex.: passwordInput )

    (So far, Chrome wont put the saved password on the input, but the form is now broken)

    Finally, to make the form work, put this code to run when the user click the submit button, or whenever you want to trigger the form submittion:

    var sI = $(".passwordInput")[0];
    $(sI).attr("id", "password");
    $(sI).attr("name", "password");
    

    In my case, I used to hav id="password" name="password" in the password input, so I put them back before trigger the submition.

    0 讨论(0)
  • 2020-11-22 01:09

    Modern Approach

    Simply make your input readonly, and on focus, remove it. This is a very simple approach and browsers will not populate readonly inputs. Therefore, this method is accepted and will never be overwritten by future browser updates.

    <input type="text" onfocus="this.removeAttribute('readonly');" readonly />
    

    The next part is optional. Style your input accordingly so that it does not look like a readonly input.

    input[readonly] {
         cursor: text;
         background-color: #fff;
    }
    

    WORKING EXAMPLE

    0 讨论(0)
  • 2020-11-22 01:09

    Change input type attribute to type="search".

    Google doesn't apply auto-fill to inputs with a type of search.

    0 讨论(0)
  • 2020-11-22 01:09

    I had a similar issue where the input field took either a name or an email. I set autocomplete="off" but Chrome still forced suggestions. Turns out it was because the placeholder text had the words "name" and "email" in it.

    For example

    <input type="text" placeholder="name or email" autocomplete="off" />
    

    I got around it by putting a zero width space into the words in the placeholder. No more Chrome autocomplete.

    <input type="text" placeholder="nam&#8203;e or emai&#8203;l" autocomplete="off" />
    
    0 讨论(0)
  • 2020-11-22 01:10

    Chrome version 34 now ignores the autocomplete=off, see this.

    Lots of discussion on whether this is a good thing or a bad thing? Whats your views?

    0 讨论(0)
  • 2020-11-22 01:13

    You can use autocomplete="new-password"

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

    Works in:

    • Chrome: 53, 54, 55
    • Firefox: 48, 49, 50
    0 讨论(0)
提交回复
热议问题