Stopping user from inputting anything other than letters and numbers
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Stopping user from inputting anything other than letters and numbers

From: Astra <No@Spam.com>
Date: Thu Aug 11 2005 - 11:49:11 CEST

Hi

I'm using the following routine on a text box to stop users from typing
anything but letters and numbers:

<SCRIPT LANGUAGE="javascript">
<!--
function CheckCodeEntry(e) {

var key = (navigator.appName == "Netscape") ? e.which : e.keyCode;

if (key == 8 || (key > 47 && key < 58) || (key > 64 && key < 91) || (key >
96 && key < 123)) {
 return true;
}
else {
 return false;
}

// 8 = backspace
// >47 to <58 = 0 to 9
// >64 to <91 = A to Z
// >96 to <123 = a to z

}
//-->
</SCRIPT>

My problem is that if somebody holds down the shift key and say 5 then % is
being entered, which I don't want. This happens for all shift key
functions.

Is there anyway round this?

Thanks

Robbie
Received on Mon Oct 24 02:14:01 2005