0

Chrome is autofilling a box on a form on a website with the login username and when you submit the form it asks to save the login.

How can I force Chrome to leave the input field alone?

It's trying to be too smart for its own good.

<input type="text" placeholder="(Optional)" name="auth_code" />

It auto-fills with the login username:

enter image description here

EDIT: I tried adding

autocomplete="off"

But the field still auto-fills with the login username on page load.

Another note:

I already have

value=""

But Chrome still auto-fills it.

Jack
  • 2,728
  • 10
  • 43
  • 50
  • Possible duplicate of [How do you disable browser Autocomplete on web form field / input tag?](http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag) – Bram Vanroy Jun 12 '16 at 09:30
  • Doesn't that remove the suggestion dropdown? I still need that. I want the value itself to be empty on page load. – Jack Jun 12 '16 at 09:39

2 Answers2

2
$(document).ready(function() {

    $('#TheInput').val('');

    setTimeout(function () {

       $('#TheInput').val('');

    }, 100);
});

This code runs twice, just in case there's a browser-specific issue. It will definitely clear the input and requires jQuery, which may or may not be an issue for you. I also added an ID to reference the input element.

<input id="TheInput" type="text" placeholder="(Optional)" name="auth_code" />
frenchie
  • 46,331
  • 96
  • 283
  • 483
  • Thanks I added some custom JS to sort it. Unfortunately it does flash for a second with the auto-fill before being empty. Bloody Chrome!!! Thanks – Jack Jun 12 '16 at 10:23
  • 1
    If it flashes, you can also hide it with css display:none so that it's not initially visible and then you change the js to $('#TheInput').val('').show() so that it will first clear then input and then display it. – frenchie Jun 12 '16 at 10:40
1

Use the autocomplete="off"

<input type="text" autocomplete="off" placeholder="(Optional)" name="auth_code" />
HudsonPH
  • 1,708
  • 2
  • 19
  • 34