Skip to content

Instantly share code, notes, and snippets.

@shaosh
Created September 23, 2016 21:11
Show Gist options
  • Save shaosh/80a72508bb00b89e546b42a0bdda0de5 to your computer and use it in GitHub Desktop.
Save shaosh/80a72508bb00b89e546b42a0bdda0de5 to your computer and use it in GitHub Desktop.
Dynamically turn autofill on and off
$('#addrBox').on('mouseup keyup', function(){
var $this = $(this);
var val = $this.val();
val = val.length;
if(val === 0){
$this.attr('autocomplete', 'on');
}
else{
$this.attr('autocomplete', 'off');
}
}).on('mousedown keydown', function(){var $this = $(this);
var val = $this.val();
var length = val.length;
if(!length){
$this.attr('autocomplete', 'new-password');
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment