[thelist] JavaScript "onKeyPress" problem

Syed Zeeshan Haider zeeshan_paki at yahoo.com
Thu Feb 21 18:37:01 CST 2002


Hi James,
Thank you for replying. Problem has been solved because of you. Thanks
again.
However, one thing is confusing. What is the philosophy behind this
problem and it's solution? Why didn't the script worked with "!=" and
"return false"? What was wrong?
Thank you,
Syed Zeeshan Haider.
http://syedzeeshanhaider.faithweb.com/

----- Original Message -----
From: "MRC" <webmaster at equilon-mrc.com>
To: <thelist at lists.evolt.org>
Subject: Re: [thelist] JavaScript "onKeyPress" problem
Date: Tue, 19 Feb 2002 13:01:27 -0800
Reply-To: thelist at lists.evolt.org

Syed,

> if(event.keyCode!=48 || event.keyCode!=49 || event.keyCode!=50 ||
...

    Change your inequality operators (!=) to equality operators (==) and
your return false to return true, but otherwise have your script return
false, then your script should work, e.g. (example abbreviated):

function checkTheKey()
{
  if(event.keyCode==48 || event.keyCode==49 || event.keyCode==50)
  {
    return true ;
  }
  return false ;
}

James Aylard



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




More information about the thelist mailing list