Reputation: 109
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
Upvotes: 1
Views: 1683
Reputation: 436
Try This Solution in JS
clearAutoFIll();
function clearAutoFIll(){
var inp = document.querySelectorAll("[autocomplete=off] input");
for(var x=0; x < inp.length; x++){
inp[x].value = "";
}
}
<form autocomplete=off>
<input type=text name="phone" />
</form>
Upvotes: 2
Reputation: 176
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);
});
Upvotes: 4