[thelist] JavaScript "onKeyPress" problem

BT Bigpant bigpant at btinternet.com
Thu Feb 21 08:32:00 CST 2002


> Change your inequality operators (!=) to equality operators (==) and
your return false to return true

or use && instead of ||
ie (x != 1 AND x != 2...)

if any of the expressions are true, it will return true;
if x = 10 then (x != 1 || x != 2) will evaluate true.

You should only use multiple OR's with equality expressions and AND's with
inequality expressions.

These are effectively the same:

(x != 1 AND x != 2)
!(x == 1 OR  x == 2)

if x is 1 or 2, it returns false, otherwise it returns true.

HTH
Phil Parker




More information about the thelist mailing list