954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

keycode showing wrong ascii value

hello all

i have a jsp page in which i am using a function for detecting the ascii value of key pressed.it has to give alert if other than any alphabet key is pressed.Below giving the explaining code

function checkname(e)
   {
             var cc=e.keyCode;

             if(cc >=65 && cc <=90 || cc >=97 && cc<=122)
             {
                         return true;
              }
           else
            {                   alert (""+cc+"");
                           alert("Enter only alphabets");
                            return false;
            }
 }

 <td><input type="text" name="name" maxlength="20" onkeypress="return checkname(event);" /></td>
                                
                                <td width="57%"><input type="text" name="user_id" maxlength="20" onkeypress="return checkname(event);"/></td>


but when i go to write any alphabet in textbox it gives alert "Enter only alphabets".i have printed the value of key pressed it is showing every time zero.Please note that this problem is occuring in Mozilla browser.In Internet explorer it is working fine as it should be.

manish250
Junior Poster in Training
88 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: