You could also check to see if the keycode is in a range. See the table below. With a quick search, I found a javascript that will check it. codes 48-57 are numbers 0-9, codes 65-90 are upper letters A-B, codes 97-122 are lower letters a-z.
ASCII table http://www.newebgroup.com/rod/newillusions/ascii.htm The JS http://javascript.internet.com/miscellaneous/ascii-character-code.html On 6/27/06, Mukta <[EMAIL PROTECTED]> wrote:
If you want to allow only characters and digits, you need not know keycodes of all the special characters. Just compare the characters' and digits' ASCII values with the character entered on OnKeyUp event. If it's a special character, just drop it. You can also use java.util.regex.Pattern and java.util.regex.Matcherclasses at server side. -----Original Message----- From: Medicherla Lakshmi [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 2:29 PM To: Struts Users Mailing List Subject: Javascript problem, how to control special characters from being entered into textbox Hi, I hava a javascript problem. I need to restrict anyone entering special characters into a textbox which is there in my html. I know that i can use onKeyPress event to handle this, but for this i need to know the keycodes. Please anyone tel me if there is any other way to handle this or tel me how to know the keycodes of the characters, so that i can use it. Also, i have to restrict the textboxes with characters and then digits. Thanks in advance. --------------------------------- Yahoo! India Answers: Share what you know. Learn something new Click here Catch all the FIFA World Cup 2006 action on Yahoo! India Click here --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]