[thelist] JavaScript "onKeyPress" problem

Syed Zeeshan Haider zeeshan_paki at yahoo.com
Tue Feb 19 14:00:00 CST 2002


Hello Everybody,
I am having a little problem with the following chunk of JavaScript
code.

function checkTheKey()
{
if(event.keyCode!=48 || event.keyCode!=49 || event.keyCode!=50 ||
event.keyCode!=51 || event.keyCode!=52 || event.keyCode!=53 ||
event.keyCode!=54 || event.keyCode!=55 || event.keyCode!=56 ||
event.keyCode!=57 || event.keyCode!=114 || event.keyCode!=111 ||
event.keyCode!=109 || event.keyCode!=97 || event.keyCode!=110 ||
event.keyCode!=82 || event.keyCode!=79 || event.keyCode!=77 ||
event.keyCode!=65 || event.keyCode!=78 || event.keyCode!=108 ||
event.keyCode!=112 || event.keyCode!=104 || event.keyCode!=76 ||
event.keyCode!=80 || event.keyCode!=72)
 {
 return false
 }
}

This function "checkTheKey()" is invoked by "onKeyPress" event which is
inserted in an <input type="text"> tag. It is perhaps obvious that I
want the user to be able to type some specific letters but the above JS
code does not allow any letter to be typed. I mean, it prevents the user
to type in the text field at all.
Can some body help me, what is the wrong with the code?
Thank you,
Syed Zeeshan Haider.
http://syedzeeshanhaider.faithweb.com/


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




More information about the thelist mailing list