How to remove auto complete input from google Chrome?

Asked

Viewed 44,013 times

23

I want to remove yellow background when this enabled auto complete from Google Chrome. I tried to disable auto complete by applying: autocomplete="off" and I was unsuccessful.

Essa é a visualização de como é pra ficar. Esse print foi tirado do Firefox

Visualização no Chrome

The top image is the view in Chrome and the bottom image is in Firefox, as it should be.

  • http://jsfiddle.net/jmn2d213/2/. Dude, you don’t have to repeat the fields. That’s the biggest scam I’ve ever seen in HTML. Put autocomplete="off" on the tag <form>. See Link in Jsfiddle.

8 answers

29


As stated here and here, it seems that currently Google Chrome ignores any kind of attribute autocomplete="off", however strange it may seem.

So a (workaround) solution to make Chrome not to do an autocomplete is to create 2 fields in a row with the same name="", one with display="none"(that will not be seen by the user) and other normal, something like that:

<form method="post">
  <input type="email" name="email" id="email_fake" class="hidden" autocomplete="off" style="display: none;" />
  <input type="email" name="email" id="email" autocomplete="off" />
  <input type="password" name="password" id="password_fake" class="hidden" autocomplete="off" style="display: none;" />
  <input type="password" name="password" id="password" autocomplete="off" />
  <input type="submit" value="Submit" />
</form>

Example also available in jsFiddle.

Update 2017

It seems that in the current versions of Google Chrome (Tested on 59.0.3071.104), it is possible to resolve it in this way:

  • autocomplete="off" on the tag form:

<form method="post" autocomplete="off">
  <input type="email" name="email" id="email" />
  <input type="password" name="password" id="password" />
  <input type="submit" value="Submit" />
</form>

Also in jsFiddle.

  • 1

    Thanks @Fernando!

  • 1

    Oloco. Really this ? Just put autocomplete="off" or autocomplete="false" in the tag of <form>. No way I’m doing this. I do this and it works.

  • 2

    OK @Taopaipai, this answer was true when it was created, if there is a better way to get the same result, you can create an updated response with example and demonstrating!

  • 1

    This alternative really is a "gambiarra", but when you have an email and a password on the same screen it seems that Chrome understands that it is a login... In the other case only the autocomplete="off" works.

5

I tried many alternatives and arrived at this:

Usually autocomplete="off" or autocomplete="on"

So I put

autocomplete="no"

Worked.

  • It worked for me. Thank you

4

Another solution I found was to disable the field, which makes the autocomplete not work in any browser (I tested it in Chrome, FF and IE).

Then just enable the field when the form is loaded, because at this point the browser will no longer fill in the fields:

<input type="email" id="email" disabled="disabled" />

And in the Javascript, after loading the document, enable the field. In this example, using jQuery:

// Esperar o documento carregar
$(document).ready(function () {
   // Usando um pequeno delay de 100ms porque às vezes o navegador preenche o campo logo que o documento está pronto, e pode não funcionar como esperado
   setTimeout(function(){
     $('#email').removeAttr('disabled');
   }, 100);
});

2

I tried to put the autocomplete in the form tag as the colleague quoted and it didn’t work. I did the duplication only email and worked for password too. No need to do for password. End of the problems with yellow fields in Chrome, I believe in other browsers too. This way worked:

<form method="post">
  <input type="email" name="email" id="email_fake" autocomplete="off" style="display: none;" />
  <input type="email" name="email" id="email" autocomplete="off" />
  <input type="password" name="password" id="password" autocomplete="off" />
  <input type="submit" value="Submit" />
</form>

2

Autocomplete="off" may not work in several cases.

I decided to add this javascript after the page onload:

var randomicAtomic = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
  $('input[type=text]').attr('autocomplete',randomicAtomic);

2

Actually just put right after resolve <input style="display: none;" />, but when you enter an info it already has a yellow background.

Use this:

input:-webkit-autofill 
{    
    -webkit-box-shadow: 0 0 0px 1000px #f9fbfd inset !important;
    -webkit-text-fill-color: #4D90FE !important;
}
  • 7

    Can you complement your answer a little more? What exactly does the code snippet do?

1

An alternative that I use and consider simple, would be putting a wait time and cleaning the values of the fields, since there is a short interval until the browser autocomplete with the suggestions, would be as follows:

With Jquery

setTimeout(function(){
  $('#user').val('');
  $('#pass').val('');
},420);

Sem Jquery

setTimeout(function(){
  document.getElementById('user').value = '';
  document.getElementById('pass').value = '';
},420);

I hope I’ve helped.

-4

I managed to solve putting only one space in the email field in value, as the browser does not find an email that is a space, it does not fill anything and this space the browser itself cleans in Submit, follows below code:

<form method="post">
    <input type="email" name="email" id="email" value=" " />
    <input type="password" name="password" id="password" />
    <input type="submit" value="Salvar" />
</form>

  • 2

    That space there will end up disabling the placeholder.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.