Autocomplete "Off" is completely ignored
Asked Answered
H

9

9

Okay, so I know how this autocomplete="off" tag is supposed to work on all inputs except a password field and I have searched for an answer to my specific problem but it looks like I'm the only one with this problem. I know I can add it to the form element or to an individual input-element. My doctype is set as: <!DOCTYPE html>.

I have a form with 2 questions (simplified for this example): Name and Phone. For testing purposes I have added the autocomplete="off" to both fields AND the form element.

This is my form:

<form id="myform" autocomplete="off">
    <input autocomplete="off" type="text" name="name" />
    <input autocomplete="off" type="text" name="phone" />
</form>

The form totally ignores the autocomplete="off" and suggests my name and phone number.

Does anybody have any idea?

Screen-shot

Hawks answered 3/4, 2015 at 12:59 Comment(6)
it might be browsers autofill setting. Not Sure though.Mukden
I can't speak Dutch but it seems you've configured Google Chrome to auto-complete your street address (click on the Instellingen voor automatisch aanvullen in Chrome link to reach the settings).Growth
Thanks Alvaro, but I never touch any browser settings. So this must be default behavior. I'll investigate this a bit further though. Although I guess that this is the whole idea of the autocomplete="off" function, right? If anyone has this set-up in their browser, that the autocomplete gets prevented anyway.Hawks
https://mcmap.net/q/57902/-disabling-chrome-autofill possible duplicate?Aq
developer.mozilla.org/en-US/docs/Web/Security/…Jeanene
#3030Fernando
V
18

The solution is actually very simple:

autocomplete="__away"

What we have done is tell any browser to completely ignore the field since __away is an air value - does not exist.

Vidar answered 27/9, 2018 at 7:16 Comment(5)
amazing elegant solution!Bendicta
Can you point to some more information about "...since __away is an air value..." ?Thyme
@Thyme It just means it is an non-existing value. autocomplete="luke" also works.Astrakhan
If it works for any unknown value, why wouldnt it work for "off". Why in the world would it accept off as "on"Audile
@DavidLatty, because Chrome purposefully chooses to ignore the value off, its a special value they detect, and then choose to ignore. They reckon they know how our website should work better than the designer.Terryterrye
T
3

Chrome unfortunately decided to ignore autocomplete="off", making it difficult on developers in hopes of maybe making some thing easier for typical users.

...we started ignoring autocomplete=off for Chrome Autofill data

Source: https://bugs.chromium.org/p/chromium/issues/detail?id=468153 (2015)

Is there a solution?

Not really... That comment continues:

In cases where you really want to disable autofill, our suggestion at this point is to utilize the autocomplete attribute to give valid, semantic meaning to your fields. If we encounter an autocomplete attribute that we don't recognize, we won't try and fill it.

But that doesn't seem to work anymore (as of Chrome 53). From the discussion here - Chrome Browser Ignoring AutoComplete=Off - as well as my own testing, there seems to no longer be a way to turn off autofill without using some kind of hack.

Thyme answered 25/9, 2016 at 18:57 Comment(1)
Even autocomplete="__away" doesn't work anymore. This is infuriating because Chrome and Edge are assuming that as developers we're stupid and they know all possible use cases and have decided in their infinite wisdom that there's no possible reason for wanting to turn it off, and when their browsers start filling fields with data that doesn't make sense we have no way to control it.Deputation
S
2

Try setting autocomplete="new-password" in the password element. This works for chrome only

Sadomasochism answered 9/5, 2017 at 9:56 Comment(0)
S
1

Try this:

$(document).ready(function(){
    $( document ).on( 'focus', ':input', function(){
        $( this ).attr( 'autocomplete', 'off' );
    });
});

Or this:

$(document).ready(function(){ 
    $("input").attr("autocomplete", "off");
}); 

On the other hand, you might have a look at this Chrome Browser Ignoring AutoComplete=Off.

Som answered 3/4, 2015 at 13:10 Comment(5)
Thanks Murat. Forgot to mention that this is something that I already tried. Doesn't make any difference.Hawks
It is very strange. Because I created a demo and tried on three different browser. Have a look at please: jsfiddle.net/fYe2p/7Errick
Yeah I know... That's exactly why it drives me insane. I have disabled all javascript that handles the form. I have removed other elements surrounding the fields. There must be something I'm missing. But I don't know what that is...Hawks
Did you try to delete the browser history and retry again?Errick
I have this form in a Foundation Reveal modal. If I place fields with the same names outside of the modal (so directly visible on page). The autocomplete works. I have tried showing the modal right away (instead of visibility:hidden), but that didn't change a thing. So it's caused by something else... but what...Hawks
O
1

Many modern browsers do not support autocomplete="off".

This is the behavior in Firefox (since version 38), Google Chrome (since 34), and Internet Explorer (since version 11).

Ornithology answered 22/12, 2016 at 22:12 Comment(0)
A
0

Try This:

<form id="myform" autocomplete="dummy-no-auto-complete-fix">
    <input autocomplete="dummy-no-auto-complete-fix" type="text" name="name" />
    <input autocomplete="dummy-no-auto-complete-fix" type="text" name="phone" />
</form>
Angiosperm answered 11/7, 2018 at 21:58 Comment(1)
That worked in chrome for me, but then firefox started allowing autocomplete, so it doesn't really help.Aintab
I
0

"off" is not working at all. I thing browser saved forms knows "off" as input identifier not a setting value. So you need random string to make browser thing that it a new input, input you see first time

$(document).ready(function(){
    $( document ).on( 'focus', ':input', function(){
        let text = "";
        let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

        for (let i = 0; i < 20; i++)
            text += possible.charAt(Math.floor(Math.random() * possible.length));
        $( this ).attr( 'autocomplete', text );
    });
});
Intermigration answered 5/10, 2018 at 15:17 Comment(1)
"off" is not working at all. I thing browser saved forms knows "off" as input identifier not a setting value. So you need random string to make browser thing that it a new input, input you see first time.Intermigration
K
0

I just fix it with

<form autocomplete="off">
your inputs
</form>

so you need autocomplete="off" in your <form> and not only in <input>

Kenleigh answered 21/11, 2018 at 16:13 Comment(2)
That doesn't matter at all. Chrome still ignores it.Aintab
also i just think wrapping each separate input in form doesn't make senseBendicta
A
0

It appears that Chrome now ignores autocomplete="off" unless it is on the tag since v34.

you can't cheat by create an hidden input over. Auto complete feature will get the first input text to fill data.

Method:1

You Can Try This One

<form id="" method="post" action="" autocomplete="off">
    <input type="text" style="display:none" />
    <input type="password" style="display:none">
    <asp:textbox autocomplete="off">
</form>
Arnold answered 18/3, 2022 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.