Disable the forms autocomplete

Asked

Viewed 1,299 times

2

Hello... I am with a problem that I thought simple, but I am two days ago looking for a solution...

I just can’t get the forms autocomplete disabled. I remembered the 'autocomplete="off"' for this, but it doesn’t work anymore.

Does anyone have an alternative for me to do this on the site? (no matter the language, the HTML will be the same after all).

PS: For Chrome, the code below does the work:

        $("input[autocomplete='off']").each(function () {

            var input = $(this);
            var id = $(this).attr("id");
            var name = $(this).attr("name");

            input.removeAttr("name").removeAttr("id");

            setTimeout(function () {
                input.attr("name", name).attr("id", id);
            }, 1);

        });

Thank you.

  • Since this attribute is not valid by W3C the staff usually enter the autocomplete="off" via javascript: field.setAttribute('autocomplete','off');

  • https://answall.com/questions/61510/como-remover-auto-complete-de-input-do-google-chrome

  • It is... I saw this "solution" and I was amazed. But it will be the way. I will apply this solution on Monday.

4 answers

0

I went through the same problem, today 10/09/2019 the only solution I found was this

put 2 false inputs before your input

<input class="hidden" type="text" style="display: none!important; visibility: hidden!important;" ></input>
<input class="hidden" type="password" style="display: none!important; visibility: hidden!important;" ></input>

-1

The autocomplete=off alone for me also does not work! But in sets with the other options works!!! Extract this line pasted above, from the login screen of the nessus vulnerabilities scanner, autocomplete is off! Nor did I have the trouble to read about each example input option above, I just copied, adapted in my codes.

  • Understand your code doesn’t work. You think it works because your browser’s autocomplete buffer for input whose attribute name is equal to Login is empty and was already empty when you implemented the code. The autoclomplete=off it prevents UA from starting an autocomplete buffer for a given name. From the moment you complete and make Submit an input with autoclomplete=on the autocomplete buffer and the autoclomplete=offnever works for this input again until you empty the cache and all browser buffers.

  • take the test <input type="text" placeholder="Login" name="login" maxlength="128" autocomplete="on" autocapitalize="off" autocorrect="off" spellcheck="false" class="form-control" aria-label="Login" aria-required="true" aria-invalid="false"> see that it works like a plague.

-1

The autocomplete="off" still works, but can also try with jQuery.

$( document ).on( 'focus', ':input', function(){
        $( this ).attr( 'autocomplete', 'off' );
    });
  • 1

    So, but if you have a text field and a password field, it no longer works. It’s in the Google Chrome documentation. And it looks like IE went that way too.

-2

According to the W3school, this is standard behavior, and it should be working.

<form action="/action_page.php" autocomplete="on"> <!-- este está habilitado -->
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
E-mail: <input type="email" name="email" autocomplete="off"><!-- Já este não --><br>
<input type="submit">
</form>

Try to check the tags, many may be the risks that might cause this.

  • 1

    This does not work, you can see that in the question itself the author says: "I remembered the 'autocomplete="off"' for this, but it doesn’t work anymore." Have you at least tested your answer to test and see if it works? Even on w3School’s own website this is right, just go there and test! http://prntscr.com/n0ym4i

Browser other questions tagged

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