Omu Omu - 1 year ago 103
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 ?

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download