Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Puntuation


Message #1 by "Natividad Castro" <natocastro@h...> on Mon, 10 Dec 2001 22:03:16 -0500
What you need to do is to check what key code the key with those characters
you want to prevent has...
This works in IE:

<html>
<head>
	<title>Keys</title>
	
	<script language="JavaScript" type="text/javascript">
    	function checkChar(e){			
			//alert(event.keyCode);
			//188 = , ;			
			//190 = . :
			var intKeyCode = event.keyCode;
			switch(intKeyCode){
				case 188:
				case 190:
					event.returnValue = false;
					event.cancelBubble = true;
					return false;
			}						
        }
    </script>	
	
</head>

<body>

<input type="text" onKeyDown="checkChar()"/>
<script language="JavaScript" type="text/javascript">
	document.getElementsByTagName("input")[0].focus();
</script>

</body>
</html>


/Robert



-----Original Message-----
From: Natividad Castro [mailto:natocastro@h...] 
Sent: den 11 december 2001 04:03
To: javascript
Subject: [javascript] Puntuation


Hi to all,
does anybody know how to stop the user from typing any puntuation in a text 
field such (;,.: etc.)?

Thank you in advanced
Nato

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp



  Return to Index