I’m trying to get immediate feedback from an input box as to the letter that has been typed into it. The input has a maxlength of 1 character and I want jQuery to be alerted to this value the moment the user lifts their key having entered their character.
The following detects the value immediately but then keeps looping forever. This isn’t strictly a problem but it seems like an undue strain.
$("#captcha").keyup(function(e) {
( $(this).val() == 'w' ) ? $(this).css("border-bottom","2px dotted #27bbb1") : $(this).css("border-bottom","2px dotted #ED0664") ;
//e.preventDefault();
});
change() won’t work as an event as this is only triggered when the user changes focus, I need this immediately after keypress.
Thanks
You are probably using the enter key to dismiss the alert, which also triggers the keyup event. Try this: