Demonstrating keyup event firing twice with autocomplete
by richardwo
HTML
<p>Type a few characters of your email address into the fields below</p>
<p><label for="with-auto">Default input field:</label> <input id="with-auto" name="email" value="" /></p>
<p><label for="no-auto">Autocomplete disabled:</label> <input id="no-auto" name="email" value="" autocomplete="off" /></p>
<p>Output:</p>
<div id="output"><div>
CSS
p {line-height:26px; font-size:14px}
JavaScript
var noautoCounter = 0;
var autoCounter = 0;
$('#no-auto').keyup(function(e) {
noautoCounter++;
$('#output').append('<p>Default input detected, counter=' + noautoCounter + '</p>');
});
$('#with-auto').keyup(function(e) {
autoCounter++;
$('#output').append('<p>Autocomplete disabled input detected, counter=' + autoCounter + '</p>');
});