Disable Chrome form autocomplete

Google Chrome ignores the autocomplete="off" or automcomplete="false" in forms.

At the time of the writing the following did the trick. You set the input field to a readonly state and remove the attribute after loading the page.

var timeoutID;
timeoutID = window.setTimeout(function() {
    $('.my-form input[readonly=""]').on('focus', function(){
}, 300);Code language: JavaScript (javascript)

Why a timeout?

If you try to remove the readonly on document ready it will not work on Chrome. Also, if you use the on focus event, the iPad keyboard will not show up.

Leave a Reply

Your email address will not be published. Required fields are marked *