Thursday, February 8, 2018

[Javascript / Chrome / EasyPeasy] Blocking form autocomplete after Chrome Canary (version 65)

Recent Google Chrome update (65) brought something that developers are not liking too much: the autocomplete="off" attribute on forms and inputs is no more considered.

Read in depth this Stack Overflow thread.

The solution (not so clear) is to give a random autocomplete value to the autocomplete attribute of each input of the form:

$('form input').each( function(){
   $(this).attr('autocomplete','no-autocomplete-'+(Math.random()*Math.random()));
});

Also apparently Chrome uses the name attribute (at least for email and password values), in my use case the name attribute was not necessary in the form so this script worked like a charm.


No comments:

Post a Comment