aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes catching ascii key codes in javascrip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "catching ascii key codes in javascrip" Watch "catching ascii key codes in javascrip" New topic
Author

catching ascii key codes in javascrip

Greg machamer
Greenhorn

Joined: May 30, 2007
Posts: 2
I've written some javascript to only allow numbers and letters to be inputed into text fields on the screen.

I've also got the code making it over write whats on the screen and not inserting the values. But when I type in a lower case a or an upper case A I'm always getting the ascii code for the upper case A.

If I press any number on the number pad I'm getting the ascii code for lowercase letters.

When I then try to insert the letter that was entered by using the ascii code it overwrites the current possition with the wrong value.

Any ideas? Besides removing or rewriting the over write feature?

Greg machamer
Greenhorn

Joined: May 30, 2007
Posts: 2
I seem to have come up with a solution. Instead of returning false inside of the stopRKey function and doing some replacing of characters, which seems to have been the problem. I'm removing the next character and then letting the current key pressed go through (of course both of these are only if the keycode is correct)

That way I don't have to call the fromCharCode function which was not returning the correct character.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Have you also played with onkeypress and see what happens?

eric
 
wood burning stoves
 
subject: catching ascii key codes in javascrip