Search code examples
javascripthtmlgoogle-chromeautocompleteautofill

Disable input field autofill (pure JS)


Does anyone know how to disable input autofill/autocomplete in 2021 using pure JS?

I've tried:

<input type="password" autocomplete="off" />
<input type="password" autofill="off" />
<input type="password" autocomplete="new-password" />
<input type="password" autofill="none" />

etc.

Also tried using jquery.disable-autofill and npm disableautofill from the stackoverflow solutions

Gonna be good if someone can share some more solutions


Solution

  • one more thing we can use autocomplete in form tag also like see below

    <form action="/form/submit" method="get" autocomplete="off">
    

    Or In JS

        $(function() {
          setTimeout(function() {
            $("input").val("");
          }, 500);
       });