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

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Dennis van Rooij
  • 91
  • 1
  • 1
  • 3
  • it might be browsers autofill setting. Not Sure though. – Ganesh Salunkhe Apr 03 '15 at 13:04
  • 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). – Álvaro González Apr 03 '15 at 13:25
  • 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. – Dennis van Rooij Apr 03 '15 at 13:41
  • http://stackoverflow.com/a/29582380/4462191 possible duplicate? – camiblanch May 06 '15 at 16:01
  • https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion – Dom Dec 22 '16 at 22:17
  • https://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag – MajiD Jul 11 '18 at 23:00

9 Answers9

17

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.

peterh
  • 11,875
  • 18
  • 85
  • 108
Peace Ngara
  • 673
  • 5
  • 7
  • amazing elegant solution! – ina Dec 08 '20 at 02:16
  • 2
    Can you point to some more information about *"...since __away is an air value..."* ? – Luke Dec 08 '20 at 15:58
  • @Luke It just means it is an non-existing value. `autocomplete="luke"` also works. – Justin Jan 20 '22 at 13:57
  • If it works for any unknown value, why wouldnt it work for "off". Why in the world would it accept off as "on" – David Latty Feb 15 '22 at 01:44
  • @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. – run_the_race Mar 24 '22 at 19:06
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.

Community
  • 1
  • 1
Luke
  • 18,811
  • 16
  • 99
  • 115
  • 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. – Vincent Jan 14 '21 at 18:03
2

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

user37416
  • 121
  • 2
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.

Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63
  • Thanks Murat. Forgot to mention that this is something that I already tried. Doesn't make any difference. – Dennis van Rooij Apr 03 '15 at 13:43
  • It is very strange. Because I created a demo and tried on three different browser. Have a look at please: https://jsfiddle.net/fYe2p/7/ – Murat Yıldız Apr 03 '15 at 14:08
  • 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... – Dennis van Rooij Apr 03 '15 at 14:13
  • Did you try to delete the browser history and retry again? – Murat Yıldız Apr 03 '15 at 14:15
  • 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... – Dennis van Rooij Apr 03 '15 at 14:24
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).

Nader
  • 336
  • 4
  • 12
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>
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 );
    });
});
Tonci14
  • 61
  • 1
  • 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. – Tonci14 Oct 05 '18 at 15:18
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>

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66
L. P.
  • 113
  • 11
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>
Jawad Altaf
  • 75
  • 1
  • 7