Omu Omu - 4 months ago 9x
Javascript Question

do an alert on keyup only if the key is a letter or number

I would like to show an alert on keyup event but only if the key was a letter or a number, not for shift,tab etc.

<input type='text' id='hi />

or for any key except for tab, shift, ctrl, enter

anybody knows how ?


You will have to attach an "keyup" event to the textbox and inside the event check for the keycodes you want:

$("#hi").bind("keyup", function(e) {
       //on letter number
       if (e.which <= 90 && e.which >= 48)