Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable HTML form input autocomplete and autofill

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...

This formation is going to prevent Chrome and Firefox to offer autofill and autocomplete for all input fields inside the form.

@zanderwar

This comment has been minimized.

Copy link

commented Mar 20, 2017

Wrong, false is not an option on autocomplete, all must be off

@Westie

This comment has been minimized.

Copy link

commented Mar 21, 2017

In addition, autocomplete=off is also a nonsense as most browsers refuse to adhere to this - the best way is to make an element [readonly] and then on hover/click/blur/focus, remove [readonly]

@jehzlau

This comment has been minimized.

Copy link

commented Oct 9, 2017

+1 to Zanderwar, false is not working. I just tried it now. :D

@Fellach

This comment has been minimized.

Copy link

commented Oct 13, 2017

@zanderwar, @jehzlau,

please read Turning_off_form_autocompletion, where it stays:

many modern browsers do not support autocomplete="off" for login fields

@RedSparr0w

This comment has been minimized.

Copy link

commented Nov 17, 2017

@Fellach The link you posted states that they do not support autocomplete="off" for login fields, all other input fields should be fine.

many modern browsers do not support autocomplete="off" for login fields

It also says you should use autocomplete="new-password" for new password fields (can be used in login fields) in order for it to not be auto filled.

If an author would like to prevent the autofilling of password fields in user management pages where a user can specify a new password for someone other than themself, autocomplete="new-password" should be specified, though support for this has not been implemented in all browsers yet.

@WarenGonzaga

This comment has been minimized.

Copy link

commented Dec 26, 2017

This is helpful for me... thanks for sharing and also some comments here are helpful!

@eloisetaylor5693

This comment has been minimized.

Copy link

commented Jan 4, 2018

Using false (or any other string that's not on or off) is a valid workaround. See bug: https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164

@swt83

This comment has been minimized.

Copy link

commented Jan 12, 2018

I had to use false to get this to actually stop the auto-fill, and I had to do it on each individual form element instead of just the form itself. This is a pretty big problem.

@anik786

This comment has been minimized.

Copy link

commented Mar 1, 2018

This works, but not the way that you think it does.

Officially it should be: autocomplete="off". However many browsers bizarrely ignore this.

Therefore it's best to just put some random string on the autocomplete section like:

autocomplete="autocomplete_off_hack_xfr4!k"

That's why autcomplete="false" accidentally works.

Note that make sure the autocomplete value for each input is different. Hence the random string at the end. Or else you may get suggestions from fields with the same autocomplete value.

@zhoolu

This comment has been minimized.

Copy link

commented Mar 8, 2018

@anik786

Thanks, this worked like a charm, autocomplete="anyrandomstring".

@kcaporaso

This comment has been minimized.

Copy link

commented May 3, 2018

These tricks no longer seem to work in Chrome 66.0.3359.139. I was using autocomplete="nope" and all of a sudden autocomplete is back on those forms. Frustrating, and this is for non-login forms, things like address, city.

@marc-thomas

This comment has been minimized.

Copy link

commented May 14, 2018

autocomplete="random" does not work anymore for type="password" fields - seems to work with type="text" and other field types :(

@thdoan

This comment has been minimized.

Copy link

commented May 15, 2018

According to MDN, "many modern browsers do not support autocomplete="off" for login fields," in which case I assume the random value hack would also not work (basically modern browsers will just ignore this attribute altogether for login fields).

@kingdonb

This comment has been minimized.

Copy link

commented May 30, 2018

@kcaporaso I think that Chrome must have finally relented on their contrarian interpretation of the standard. I'm encountering this issue for the first time, and autocomplete="off" on the form tag seems to work, even in spite of thousands of complaints scattered across every help site on the internet claiming to the contrary.

Thank you for your post, I was beginning to think I was crazy but if I'm right and you're right, then I guess the behavior has been changed by an update within the last month or two.

@hugocruz

This comment has been minimized.

Copy link

commented Jun 18, 2018

As @thdoan referenced the MDN article explains more about it.
Most relevant for me was:

In some cases, the browser will continue suggesting autocompletion values even if the autocomplete attribute is set to off. This unexpected behavior can be quite puzzling for developers. The trick to really enforcing non-autocompletion is to assign an invalid value to the attribute, for example:

autocomplete="nope"

Since this value is not a valid one for the autocomplete attribute, the browser has no way to match it, and stops trying to autocomplete the field.

This explains why false works as stated above.

Edit: I'm using Chrome Version 67.0.3396.87 (Official Build) (64-bit)

@benbonnet

This comment has been minimized.

Copy link

commented Jun 29, 2018

@kingdonb so then I'll scatter another one here as it looks like the issue is back again, stronger than ever

@jprasmussen

This comment has been minimized.

Copy link

commented Jul 6, 2018

Adding autocomplete="off" to a text input worked for me in Chrome.

@Acidic9

This comment has been minimized.

Copy link

commented Jul 9, 2018

Nothing seems to work for me in Google Chrome..

@Abolfazl

This comment has been minimized.

Copy link

commented Jul 10, 2018

I have tried various options and nothing is working for me in Chrome.

@raphael22

This comment has been minimized.

Copy link

commented Jul 17, 2018

So... autocomplete='off' trigger a warning telling me to precise my autocomplete...
autocomplete='false' or another value not in spec does remove the warning but try to autocomplete with previous value known by the input...
This spec is a ****ing mess !

@erik2504

This comment has been minimized.

Copy link

commented Jul 25, 2018

It's back again indeed. In v68 it ignores all known workarounds to prevent auto-filling fields.
autocomplete="random-string-here" is broken. The autocomplete="off" gets ignored. Even using the method where you make your fields readonly and remove that attribute on focus doesnt seem to work anymore....

@fschlaef

This comment has been minimized.

Copy link

commented Jul 25, 2018

Nothing works. All my search fields retain recently entered values, which is completely idiotic, and tons of developers are looking like idiots for not being able to remove this, all because Google thinks their idea of "user experience" is the best and nobody should question it. Very well done.

@JefferyHus

This comment has been minimized.

Copy link

commented Jul 25, 2018

Since everyone is pissed off by google, maybe this trick can help you around, assign wrong values to autocomplete attribute.
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

@lancegliser

This comment has been minimized.

Copy link

commented Aug 1, 2018

I'm currently forced to do a browser specific sniff. If it's chrome, use autocomplete="disabled" which handles both autocomplete and address based autofill (two separate things):

// Weird browser specific hack, because autofill isn't autocomplete
// Chrome demands disabled to turn it off
element.autocomplete = isGoogleChrome() ? 'disabled' :  'off';

For reference, here's the most up to date sniffer I found:
https://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome

I feel terrible having to do this

@Adavis619

This comment has been minimized.

Copy link

commented Aug 13, 2018

autocomplete="off" works for me in IE, Chrome, and FF.

@MissIrina

This comment has been minimized.

Copy link

commented Aug 14, 2018

This worked for me -> autocomplete="anyrandomstring".

@GuiDeto

This comment has been minimized.

Copy link

commented Aug 14, 2018

autocomplete="new-password"

@mitchellurgero

This comment has been minimized.

Copy link

commented Aug 17, 2018

None of this worked for me so I used (Requires jQuery):

...
<input class="user" type="password" id="pass" class="form-control" placeholder="Account Password" name="password" value="" readonly>
...

<script>
$( document ).ready(function() {
    setTimeout(function(){
        $("#pass").attr('readonly', false);
        $("#pass").focus();
    },500);
});
</script>

Which so far has worked in IE10+, Chrome, Firefox, Safari, etc. (Pretty much every web browser used in this day and age.)

Also works in IE9, but who uses that?!

@imegory

This comment has been minimized.

Copy link

commented Sep 22, 2018

My two cents on this subject: on Chrome, autocomplete="nope" seems to work. Trying autocomplete="off" seems to be ignored by Chrome. I am pretty amazed that this has not been settled at the W3C level.

@IamCharmaineJoy

This comment has been minimized.

Copy link

commented Sep 26, 2018

autocomplete="off" works for me in Chrome 69 on macOS (Sierra) and safari

@greenjackal

This comment has been minimized.

Copy link

commented Sep 28, 2018

A jQuery plugin can solve this problem for all browsers.
https://github.com/terrylinooo/jquery.disableAutoFill

@rubensfernandes

This comment has been minimized.

Copy link

commented Oct 17, 2018

use autocomplete="anyrandomstring"
And dont use id="password" or id="email", use anything else like id="field1" this should be works!

@chriscooning

This comment has been minimized.

Copy link

commented Oct 17, 2018

having to change the name of the id seems very wrong / broken to me - this is especially tedious when you have large forms.
The jQuery plugin is the only thing I've found that works in chrome.

What a shame.

@jbgraug

This comment has been minimized.

Copy link

commented Oct 25, 2018

Just remove the name attribute

@CharlyPoppins

This comment has been minimized.

Copy link

commented Nov 6, 2018

Nice workaround, thank you :)

@salmanmd786

This comment has been minimized.

Copy link

commented Nov 14, 2018

Just remove the name attribute

After so many trails, luckily your solution works. Kudos.

@DanNeely

This comment has been minimized.

Copy link

commented Nov 21, 2018

The jquery plugin is also preventing the PW from being *ed out by default. That's terrible in a different way.

@mandaputtra

This comment has been minimized.

Copy link

commented Nov 28, 2018

You should updated this gist man, many person googled see this

@dhniels

This comment has been minimized.

Copy link

commented Nov 30, 2018

The only thing I've been able to get to work is autocomplete="new-password" on each input i want it disabled (see the answer by "tibalt" in this stack overflow post)

only tested on chrome 70 so far.

Is there any "one size fits all" solution for this? This spec seems to be a total shitshow. Dependent on browser, attributes, type, input-only vs. form-wide, mobile vs desktop, etc. Disastrous.

UPDATE: testing on chrome, if I had a name attribute, it breaks. so this only works (in chrome, anyway) if name is not set.

@mariusrazoux

This comment has been minimized.

Copy link

commented Dec 3, 2018

<input type="text"
      id="search"
      autocomplete="off"
      autocorrect="off"
      autocapitalize="none"
      spellcheck="false" />

works for me without removing the name attr

@lmpampaletakis

This comment has been minimized.

Copy link

commented Dec 4, 2018

The thing is to work for passwords too. And when I say work, I mean one solid solution

@stiv-yakovenko

This comment has been minimized.

Copy link

commented Dec 15, 2018

autocomplete="nope" worked for me, autocomplete="off" didn't

@JeanCollas

This comment has been minimized.

Copy link

commented Dec 17, 2018

Feel free to vote and comment on the bugtracker... I did not find any valid solution yet. Once address autofill is enabled, it covers ggle place autocomplete....

https://bugs.chromium.org/p/chromium/issues/detail?id=587466

@cimoskill

This comment has been minimized.

Copy link

commented Dec 19, 2018

For me I confirm the best way is plain inline javascript like:
<input type="text" name="email" class="form-control" readonly="readonly" onfocus="javascript: this.removeAttribute('readonly')" />
I added the readonly attribute from start and the onfocus inline js.
I really don't like this kind of things, but I think it's far better than "removing the name attribute" omg.
Incredible issue btw.
Ciao!

@troyanvic

This comment has been minimized.

Copy link

commented Dec 19, 2018

for input tag attribute autocomplete should be off, for example <input id="date" type="text" name="date" value="2018/12/19" autocomplete="off" />

@cimoskill

This comment has been minimized.

Copy link

commented Dec 19, 2018

@troyanvic yes but that solutions doesn't work on all browsers. I still had all my form with autocomplete="off" and on each input element. That's the central point of this topic. Cya

@NicolayD

This comment has been minimized.

Copy link

commented Jan 7, 2019

For me, "off" and "false" don't work but any other string I tried, including "nope", did work.

@danielgary

This comment has been minimized.

Copy link

commented Jan 15, 2019

Hope this helps, set the autoComplete="nope" on the form element

              <form autocomplete="nope">
@LucasBSC

This comment has been minimized.

Copy link

commented Jan 17, 2019

nope incredibly worked for me lol

@tomheathershub

This comment has been minimized.

Copy link

commented Jan 23, 2019

Same for me! very strange

@CaptainN

This comment has been minimized.

Copy link

commented Jan 26, 2019

Why is this still so hard to control in 2019 - what the heck Google?!

None of the options on this page worked for me. I even tried changing the value to:

autoComplete="Chrome, stop autofilling. You don't know better than me. Why have you made this hard?"

This works for now, but I'm sure Google will make it needlessly hard again in a few weeks:

<input style={{ position: 'fixed', left: -1000 }} type="text" name="username" id="username" />
<input style={{ position: 'fixed', left: -1000 }} type="password" name="password" id="password" />

This unfortunately leaves these items in the tab progression, which is not great for accessibility, and demonstrates how Google's attempts to override my decisions as the app developer is counter productive. This should be a simple switch. I want it off.

@MonsterGameDev

This comment has been minimized.

Copy link

commented Jan 29, 2019

right now - to prevent both autofill and autocomplete i use autocomplete="off" in the form-tag and autocomplete="xpqrz" on every input then i wont suggest ANYTHING
(Chrome Version 71.0.3578.98)

@WuglyakBolgoink

This comment has been minimized.

Copy link

commented Feb 10, 2019

FYI: @MonsterGameDev

autocomplete="off" in the form-tag and autocomplete="xpqrz" on every input

Doesn't work on Version Chrome Version 71.0.3578.98 (Form was created in angular@7 App)

@dmausner

This comment has been minimized.

Copy link

commented Feb 13, 2019

Chrome 71.0.3578.127 (Official Build) (64-bit) under ChromeOS (using a ChromeBook client):
<input id=xxxxx autocomplete=none ...> (not linked to a form, no name attribute) WORKED -- no automatic suggestions.

Assume that "none" is equivalent to a random text value.

@dennisjnolan

This comment has been minimized.

Copy link

commented Feb 24, 2019

This situation is crazy. None of the hacks work for me on an iMac localhost app.
What is ridiculous is that a single text input field which is above a list of names and is used as input to filter the list blocks the first few names of the list as soon as it gets focus.
But text input fields in a dialog or modal dialog do not have this problem. So why do input tags behave differently in dialog tags to other tabs.
In my opinion this inconsistency is a bug.
Unfortunately I need modal dialogs and neither Safari nor Firefox have them yet. But they do not have that stupid suggestion box when clicking into the input field.
I noticed that it disappeared when I pressed the escape key. If it cheeses me off enough I will probably have to find a way to send an escape key event in an on focus event handler.
But shouldn't boolean attributes be disabled/off by default?

@HoldenCreative

This comment has been minimized.

Copy link

commented Mar 1, 2019

Why is this still so hard to control in 2019 - what the heck Google?!

None of the options on this page worked for me. I even tried changing the value to:

autoComplete="Chrome, stop autofilling. You don't know better than me. Why have you made this hard?"

This works for now, but I'm sure Google will make it needlessly hard again in a few weeks:

<input style={{ position: 'fixed', left: -1000 }} type="text" name="username" id="username" />
<input style={{ position: 'fixed', left: -1000 }} type="password" name="password" id="password" />

This unfortunately leaves these items in the tab progression, which is not great for accessibility, and demonstrates how Google's attempts to override my decisions as the app developer is counter productive. This should be a simple switch. I want it off.

Not sure if this hack is still valid, but you could modify the tabindex property for that specific issue. We've had no luck here though, Chrome seems dedicated to overwriting the prior methods of preventing autofill/autocomplete.

@prideptg

This comment has been minimized.

Copy link

commented Mar 5, 2019

As of right now, I'm having luck with autocomplete="!off">

Can't tell you why.

@tymothytym

This comment has been minimized.

Copy link

commented Mar 9, 2019

<form><input type="text" id="something" pattern="[ \S]+" autocomplete="off"></form>

Now works for me in Chrome 72.0.3626.121 having never worked previously.

I had been using <input type="text" id="something" pattern="[ \S]+" role="presentation" autocomplete="nope"> but that now doesn't work.

@sb2059

This comment has been minimized.

Copy link

commented Mar 12, 2019

We need an open-source, mainstream replacement for chrome that isn't vulnerable to massively expensive human error like this that can't be quickly resolved.

@yashanandan

This comment has been minimized.

Copy link

commented Mar 14, 2019

I am facing this issue recently but I noticed that if I remove my id there is not autocomplete. I am having an input box that is not under a form. Can anyone see if they are having the same experience ?
<input type="text" class="auto-sugg-text" id="autosuggest-head-txt" autocomplete="off">
doesn't seem to work but this does
<input type="text" class="auto-sugg-text" autocomplete="off">

@mhaava

This comment has been minimized.

Copy link

commented Mar 14, 2019

<input type="text" name="name" readonly="readonly">

$(function() {
        setTimeout(function() {
            $('input[name="name"]').prop('readonly', false);
        }, 50);
    });
@stevenvachon

This comment has been minimized.

Copy link

commented Mar 19, 2019

As per @yashanandan's comment, removing the id solved the issue for me as well.

@kareha

This comment has been minimized.

Copy link

commented Mar 20, 2019

Add this at the first line after <form>
<input type="password" style="display:none;" readonly>

Browsers are looking for the first occurrence of a password type field, they fill that with the password and the field before that with username.
Nothing else helps. Even no timeout stuff and changing attributes.

@lyallb

This comment has been minimized.

Copy link

commented Mar 21, 2019

I am using chrome 73.03683.86
i set my username input field and password field in a form to autocomplete=''
and the console message about autocomplete went away
hope this helps

@eggerand13

This comment has been minimized.

Copy link

commented Mar 22, 2019

@kareha
That is actually a good idea as a workaround. Still pretty terrible that we have to hack this way.

@gregmousseau

This comment has been minimized.

Copy link

commented Mar 24, 2019

Currently, this seems to work (Chrome v73, FF v66):

$('form, input, select').attr('autocomplete', 'nope')

@gillytech

This comment has been minimized.

Copy link

commented Mar 25, 2019

In addition, autocomplete=off is also a nonsense as most browsers refuse to adhere to this - the best way is to make an element [readonly] and then on hover/click/blur/focus, remove [readonly]

@Westie Your suggestion about combination readonly and some JS has worked perfectly. Thanks for the tip!

@matheusioxi

This comment has been minimized.

Copy link

commented Mar 25, 2019

$('form, input, select').attr('autocomplete', 'nope')

Isto funcionou comigo no meu projeto em asp.net forms

@Crixin

This comment has been minimized.

Copy link

commented Apr 1, 2019

Use this, it's working for me!
<input autocomplete="nope" type="text">

@Jackiedk100

This comment has been minimized.

Copy link

commented Apr 2, 2019

Use this, it's working for me!
<input autocomplete="nope" type="text">

Not working here.. :(

@Crixin

This comment has been minimized.

Copy link

commented Apr 3, 2019

Use this, it's working for me!
<input autocomplete="nope" type="text">

Not working here.. :(

@Jackiedk100 What is your browser and version?

@singelone

This comment has been minimized.

Copy link

commented Apr 4, 2019

try to remove your id attribute.it's working for me

@derrickpeavy

This comment has been minimized.

Copy link

commented Apr 9, 2019

In Safari, nothing works. I've even renamed the fields to "fieldName&randomNumber" like so:
name="amount8764876234" value="myValue"
Doesn't matter. On initial reload, the old value is in the form field. I have to do a second reload or empty cache plus reload to see the correct values that were just submitted.

@derrickpeavy

This comment has been minimized.

Copy link

commented Apr 10, 2019

SOLUTION!

So, I see that some people are having luck with certain attributes, javascript, etc. But the problem is that the browser is caching the URL and the page content.

And, it's the URL that has proven to be the problem and the solution (at least for me).

For example, www.site.com/myFormPage.ext?var=value&var2=value2

At least as far as Safari was/is concerned, it appeared that as long as it could find the URL in history, it was going to fill in the form fields with the prior values come hell or high water.

I tried generating random numbers dynamically on the form (name="myField863598365") and that would change on each page load. The form processing evaluates the name and chops off the number, no problem. But Safari still cached the prior page content even with unique and always changing names.

autocomplete="pick any thing you want" - didn't matter.

javascript didn't make a difference

So, when editing data on a form that you are developing, if the URL can be retrieved from cache and still be valid, nothing worked. It appeared that Safari was looking only at the URL string, and the vars in the URL. So, www.site.com/myFormPage.ext?var=value&var2=value2 would always be cached - even if the values changed on submission, the prior values would be shown for that URL string with those vars.

Again, as an example, www.site.com/myFormPage.ext?var=value&var2=value2.... Load the form, change a value, submit the form - the old values show up on reload. You then have to force the cache to be emptied, or a second page load, only then would either option show the new form value.

Not acceptable. Users are going to be confused.

Here is what worked.

In the case of web development, you are sort of always "rolling your own solution." So, instead of using url vars and values (example: www.site.com/myFormPage.ext?var=value&var2=value2). I added a field to my database for a pseudo/fake link value which is randomly generated EVERY TIME the form is submitted.

I then use that value in my URL like so: www.site.com/myFormPage/896983642/

Or, it can also be just www.site.com/896983642/

Notice no file extensions or url vars!

The trick of course is how to process that. But again, you are already "rolling your own." So, in my framework, I scan the URL string and process the pseudo/fake directories with a combination of modRewrite and server side processing. This is not unlike what WordPress does with SEO friendly links.

In this case, the framework of the application looks up the /896983642/ section and matches it to a record that I am trying to edit, then loads the correct page, using the correct values in the session scope without passing them through the URL.

Because /896983642/ is unique and changes on EACH record update, the URL is always unique to the browser and so it can never retrieve those old form values from cache. And of course there are checks and safeguards in the framework to process the URL string and avoid nefarious injections.

So, bottom line apparently, the browser has to see a unique URL each time you load the form. And while it's a pain in the ass, it also creates it's own level of data protection in that no URL is ever reused.

I suspect that more browsers will gradually force caching of some level like Safari is doing. Not because Safari is all that and a cup of tea, but because it's a way to add speed and reduce bandwidth (or so some people think - because while it might reduce bandwidth by a few bytes, it's actually a problem for data integrity and user experience, leading to either a second page load (more bandwidth) or a support ticket).

So while Safari has removed it's "Disable Caches" option and perhaps other browsers have not (removed the equivalent), I wouldn't be surprised based on this thread and Google searches if this continues to be an issue in all browsers going forward. If so, then a unique and disposable URL is all you have left to fight with.

@kreba

This comment has been minimized.

Copy link

commented Apr 14, 2019

@kareha's suggestion to soak up the browser's autocomplete attempt with a hidden dummy field worked like a charm.

@PABretherton

This comment has been minimized.

Copy link

commented Apr 15, 2019

I just made an account so I could chime in. The answer is to use either a textarea or a div with contenteditable.

@LouisOfEidex

This comment has been minimized.

Copy link

commented Apr 15, 2019

I've been following this thread for the last month trying to fix a bug where chrome's autocomplete is over our bootstrap typeahead. I have a few partial solutions. The first I was able to implement was autocomplete="disabled" but it will only remove the autocomplete feature from filling out multiple input fields. Currently it will suggest an autocomplete for the current input but won't autofill other inputs.
Next, I tried to a css hack to remove the autocomplete which works only when you hover over the input then the autocomplete flashes away.

<style> {` input:-webkit-autofill { display:none; `} </style>

I'm no css wizard so any suggestions will help, Thanks.

@ilken

This comment has been minimized.

Copy link

commented Apr 15, 2019

Remove id and set autocomplete to off and it should work with the latest Chrome version.

<input autocomplete="off" type="text"/>

@LouisOfEidex

This comment has been minimized.

Copy link

commented Apr 15, 2019

@ilken thank you for the feedback but I am on the lasted chrome version 73.0.3683.103 (Official Build) (64-bit), and latest version of React.
<input autocomplete="off" type="text"/> is still ignored and will autofill the whole form.
<input autocomplete="anyRandomString" type="text"/> will autofill the current input but not the whole form.

EDIT: Fixed, changed placeholder to a non location based name!!!

@MorevM

This comment has been minimized.

Copy link

commented Apr 16, 2019

$('form, input').each(function() {
$(this).attr('autocomplete', 'si_fuck_off_this_autocomplete');
});

Works good for me.

@xama

This comment has been minimized.

Copy link

commented Apr 18, 2019

So.. the ultimate solution of this heavy weight story is just to put any string you want as value of autovomplete ? strange but did the job !
<input type="x" name="y" autocomplete="whatever" />

@spartha1995

This comment has been minimized.

Copy link

commented Apr 23, 2019

These tricks no longer seem to work for chrome as well as in firefox

@derrickpeavy

This comment has been minimized.

Copy link

commented Apr 23, 2019

None of the "tricks" will ever work for very long. The browser wants to give you speed over accuracy so it will autocomplete as long as it thinks you are loading the same page. As long as the URL does not change, you will not solve this 100% of the time.

The only way to fix this is to load unique URL's each time for the same page. It's a pain, but it's quite easy to do if you are developing the form and data structure yourself already.

Take a look at the answer I posted earlier. Not only will it always load the correct data, but the link itself is safer because it is always unique. Forms don't need to be SEO'd, so that is not a problem.

@jhaidze

This comment has been minimized.

Copy link

commented Apr 24, 2019

A potential workaround that I'm currently using is to set 'autocomplete="disabled"'
and then to avoid the attribute value switch, add a script similar to

setTimeout(function(){ $('input').attr('autocomplete', 'disabled'); }, 400);

I'm not sure what the potential drawbacks are, but it's working for the moment.

@xeon826

This comment has been minimized.

Copy link

commented Apr 25, 2019

I did autocomplete="new-password" for a few inputs. I believe it only works for at most two on the same page which in my case wouldn't suffice for my search form that has many inputs so I just did

  $('input').on('focus', function(obj) { // disable autofill
    $('input').removeAttr('autocomplete');
    $(this).attr('autocomplete', 'new-password');
  })
@brandonbird

This comment has been minimized.

Copy link

commented May 16, 2019

@kareha 's solution looked like the best trick but Chrome seems to have started to check the css visibility of the input and so it didn't work for us. Inspired by that solution, instead of trying to make the decoy input invisible we just positioned it way off-screen.

<input type="password" name="password" style="position: absolute; right: -20000px">

This seems to be working... for now.

@shubhamcompro

This comment has been minimized.

Copy link

commented May 21, 2019

This is working fine.
<input type="password" autocomplete="new-password" name="password">

Refer https://stackoverflow.com/questions/15738259/disabling-chrome-autofill

@anish-techpro

This comment has been minimized.

Copy link

commented May 23, 2019

In addition, autocomplete=off is also a nonsense as most browsers refuse to adhere to this - the best way is to make an element [readonly] and then on hover/click/blur/focus, remove [readonly]

this works for me

@snowballrandom

This comment has been minimized.

Copy link

commented May 27, 2019

For me this seems to be doing the trick. Im sure this can be made to be a little more elegant ;)

  <form name="myForm" >
    <input name=r_email" type="text" readonly="true">
// Clear Form On Load
function clearForm(){
    document.registerForm.reset();
    
    var email = $('input[name="r_email"]');
    var password = $('input[name="r_password"]');
    
    email.val('');
    password.val('');
    
    email.attr('readonly', false);
    password.attr('readonly', false);
    
    
}
$(document).ready(function(){
    clearForm();
});

You may want to try to substitute:

$(document).ready()

With

$( window ).on( "load", function() { ... })

@hotelratepro

This comment has been minimized.

Copy link

commented May 27, 2019

As per @yashanandan's comment, removing the id solved the issue for me as well.

I tried everything before this (all variation of autocomplete="{something}" and this is the only one that worked, thanks!
(I'm using 74.0.3729.131)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.