View Single Post
  #3 (permalink)  
Old September 8th, 2008, 10:09 AM
sbkrohit sbkrohit is offline
Registered User
 
Join Date: Sep 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply!

This is what I could come up with

<html>
<head>
<script>


function checkChar(e)
{
    var keynum;
    if(window.event) // IE
      {
          keynum = e.keyCode;
      }
    else if(e.which) // Netscape/Firefox/Opera
      {
      keynum = e.which;
      }
    if(keynum=16)
    {
        cnt=1;
    }
    if(keynum==55||keynum==61)
    {
        return false;
    }

}




</script>

</head>
<body>

<form action="">
First name:
<input type="text" name="firstname" onkeydown="return checkChar(event)">
<br>
Last name:
<input type="text" name="lastname">
</form>

</body>
</html>

The problem is that the shift press is also being treated as a event and when I click on number 7 for & ,the ascii code obtained is 55 which is for number 7 and not for & . So now 7 and & are not printing but I dont want only special characters.

Thank You

Reply With Quote