-
Keypress event
I want to return keycode 0 when the user enters anything else than a number in a textbox.
I have made a eventhandler, I check the keycode or the which if the navigator is a netscape.
If the ascii code is anything else than a number I set the keycode = 0 in IE, and the which in netscape = 0. This works in IE, why not in Netscape???
Help needed...
/Smirre
-
Hi Smirre
I usually just do it on the OnBlur event of the text field !
here's my function
Code:
function isNum(txt){
if (isNaN(txt.value)){
alert('Numbers only!');
txt.focus();
txt.select();
}
}
usage:
onBlur="isNum(this);"