I am having this issue with Chrome autofill fields where Chrome is ignoring 'autocmplete="false|off|others"'. I also tried the hidden fake fields, this, this and few more. It does not seem to be working.The fields become yellow and contain password, for which I decided to use the following CSS rule:
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill
{
-webkit-box-shadow: 0 0 0 1000px white inset !important;
}
with javascript:
$(window).load(function() {
console.log('Inside JQuery Window.Load...');
if(document.querySelector("input:-webkit-autofill")!= null) {
document.querySelector("input:-webkit-autofill").value = "";
}
console.log('Autofill value(Before Alert): ' + document.querySelector("input:-webkit-autofill"));
alert('An alert...');
if(document.querySelector("input:-webkit-autofill")!= null) {
document.querySelector("input:-webkit-autofill").value = "";
}
console.log('Autofill value(After Alert): ' + document.querySelector("input:-webkit-autofill"));
});
to overwrite the field manually.
Here is the log output from the above script:
Inside JQuery Window.Load...
XXX:1324 Autofill value(Before Alert): null
XXX:1329 Autofill value(After Alert): [object HTMLInputElement]
And when this is running in debug mode:
Inside JQuery Window.Load...
XXX:1324 Autofill value(Before Alert): [object HTMLInputElement]
XXX:1329 Autofill value(After Alert): [object HTMLInputElement]
I tried the following permutations with:
$('input:-webkit-autofill').each(function(){...});
window.document.querySelector("input:-webkit-autofill");
<body onload="chromeCheckAutofill();" />
<script>
function checkAutofill() {
if(document.querySelector("input:-webkit-autofill")!= null) {
document.querySelector("input:-webkit-autofill").value = "";
}
}
</script>
This is the field with issue:
<input name="MY_REFNO" id="MY_REFNO" style="WIDTH: 180px" maxlength="16" onkeypress="upperAlphanumberHandler(event)" onblur="upperAlphanumberChecker('MY_REFNO')" value="" autocomplete="off">
What am I doing wrong? How do I fix this...