Is there any way to disable autocomplete on a text field in chrome 66? I have tried a number of options like :
Can anyone help me with this?
Also, one more thing does chrome automatically enables autocomplete for a username if it has a password type field below it?
I acheived the auto complete functionality to be disabled in chrome by giving
<form autocomplete="off">
and
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
element.autocomplete = isChrome ? 'disabled' : 'off';
where isGoogleChrome is a function to find whether the browser is chrome written with help of this post.
JavaScript: How to find out if the user browser is Chrome?
I used this code and it is working for me. I hope it will also helpful for you. :) Enter your type with readonly and then below mention code.
<input readonly type="email" onfocus="if (this.hasAttribute('readonly')) {
this.removeAttribute('readonly');
this.blur(); this.focus(); }" />
$(document).ready(function(){
$("input").val("");
});
So, Chrome just sets the value of element when autofilling them. Just try that, else you can try set some interval, wich will check value in HTML code, because Chrome not put new value to HTML code, just puts it in memory for itself.
A lot of browsers refuse to adhere to what you have mentioned - the best way is to make an element readonly
and then on hover/click/blur/focus, remove readonly
.
So you could give it a class such as disable_autocomplete and also make the input field readonly.
Then when the field is hovered, focussed, or clicked you can remove readonly. Optionally, add it back when unfocussed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With