10

With chrome 66 I couldn't find a way to disable autocomplete on text inputs like it used to work. I tried autocomplete="off" and autocomplete="new-password" which worked until Chrome 63 I think but doesn't anymore.

Is there a new way to disable this feature ?

Thanks !

jojo____
  • 207
  • 3
  • 14
  • Maybe this could help you: https://stackoverflow.com/questions/15738259/disabling-chrome-autofill – Fabio_MO Apr 27 '18 at 15:21
  • Try `aria-autocomplete="none"` and see if anything changes? @SSH. Also doesn't https://stackoverflow.com/a/50238206/2830850 help? – Tarun Lalwani May 18 '18 at 08:16

4 Answers4

5

Just ran into this -- Google looks at the fields id or name to determine if it has saved data for that field. As a site author, use a randomly generated name/id, and/or add an autocomplete=<random string> to the field.

See this playground: https://jsfiddle.net/mfdc22pz/1/

BTW Chrome Canary (68) fixes this bug!

In Short: Add random tags like: name="foo_90553-4"

penduDev
  • 4,301
  • 28
  • 34
Moos
  • 537
  • 4
  • 8
  • Checked this with Chrome 68 and confirmed autocomplete is gone! I guess we'll just recommend people using IE or Firefox until Chrome 68 gets released. Thanks a lot for your help. – SSH May 24 '18 at 06:44
  • 2
    @Moos When you say Chrome 68 fixes the bug, do you mean you were able to get it to honor the `autocomplete=off` flag? Just tested in Canary 69 and can't seem to get it working. – Sheng Slogar Jun 02 '18 at 17:07
  • Google looks at the name attribute only. Not the id. Using a random name is troublesome if you're going to be looking at post data. – png Aug 10 '18 at 18:42
  • Yes, some on my version 69 – Sebastien Oct 05 '18 at 13:27
  • Working in March 2019 – penduDev Mar 15 '19 at 13:58
2

I resolved using a little jQuery (but you can use a simple javascript).

The problem is that chrome looks at the name and/or the id of your fields. The only solution I found is to remove those attributes, add an data-name attribute with the real name of the field, and re-attach the name attribute after the submit using javascript.

There is an example

<form onsubmit="return formSubmit(this);" autocomplete="off">
    <input type="text" data-name="dateStart" class="form-control" />
</form>


<script>
function formSubmit(form) {
  console.log(form);
  $(form).find('.form-control').each(function(){
    $(this).attr('name', $(this).data('name'));
  });
  console.log(form);
  query = jQuery(form).serialize();
  window.open("/YOUR_URL/?" + query, "_self");
  return false;
};
</script>
1

I got the same issue. Work around with insert invisible input make it like first input on page.

[Html] ... ... [css] ... .invisible_input{height: 0.1px;position: absolute;margin-top: -500px;} ...

But waiting for answer from chrome developer:/ I hope this help you! enter image description here

K.Dinh
  • 39
  • 3
  • Tried every permutation of autofill / autocomplete "off", "foobar", etc. The hidden input was that only thing that worked. Thanks! – IrkenInvader May 10 '18 at 19:15
  • It's seem chrome newest version have fixed this issue. Check out newest version off chrome(V.67.....) – K.Dinh Jun 12 '18 at 02:42
0

What's working for me is using a non-password input that pretends to have a password mask - battling the browser vendors to turn off autocomplete on actual password fields will probably end in frustration..

Here's a sandbox: https://codesandbox.io/s/yp3pyl4rkv

A similar approach with more features is at https://github.com/karaggeorge/react-better-password

eug
  • 1,088
  • 1
  • 17
  • 24