Tried several methods of disabling autocomplete and Chrome still ignores it when using jQuery Select2 input.
I tried inserting another input field (and using display: none) before the real input to try to trick Chrome, this didn't seem to work either.
Here is how the input looks now:
<input type="text" autocomplete="off" autocorrect="off"
autocapitalize="off" spellcheck="false" class="select2-input select2-default" id="s2id_autogen2" placeholder="" style="width: 283px;" aria-activedescendant="select2-result-label-3">
When clicking on the field, at least half the time Chrome will try to autocomplete it with my phone numbers saved in Chrome. Any ideas how to disable it? It also inhibits the Select2 use as it covers it's options up.
Chrome intentionally ignores autocomplete=“off” and autocomplete=“false”. However, they put new-password in as a special clause to stop new password forms from being auto-filled.
Chrome respects autocomplete=off only when there is at least one other input element in the form with any other autocomplete value. This will not work with password fields--those are handled very differently in Chrome.
It's Simple try it
<script type="text/javascript" charset="UTF-8">
$(document).ready(function(){
$( document ).on( 'focus', ':input', function(){
$( this ).attr( 'autocomplete', 'new-password' );
});
$( "input.select2-input" ).attr( 'autocomplete', 'new-password' );
});
</script>
Simply wrap your input in <form autocomplete="off">
<form autocomplete="off">
<input type="text" ...>
</form>
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