Ladies and Gentlemen, hello. This is my first post here ever.
The following two simple examples are to perform the same task - block numeric input in text field, except one of the works in Opera and the other one doesn't:
Example from W3 Schools - DOES NOT WORK!
if(window.event) // IE
keynum = e.keyCode;
else if(e.which) // Netscape/Firefox/Opera
keynum = e.which;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
<input type="text" onkeydown="return noNumbers(event)" />
Example from MR ED KJ - WORKS!
var key = window.event ? e.keyCode : e.which;
var keychar = String.fromCharCode(key);
reg = /\d/;
<input type="text" onkeypress="return onKeyPressBlockNumbers(event);" />
The scripts were tested under Windows XP Pro SP3 using the following browsers:
IE: 8.0.6001. 18702IC
Safari 3.2.1 (525.27.1)
Any ideas what the reason may be? There's good chance this problem will be popping up frequently in the future, so it would really help to know what makes those things tick.
Thank you for your time.