You might also consider the StringContentValid tag in the JSTags taglib from Java Web Parts:
http://javawebparts.sourceforge.net Specifically: http://javawebparts.sourceforge.net/javadocs/javawebparts/taglib/jstags/StringContentValidTag.html I *think* you can do: <input type="text" onKeyUp="return JWPStringContentValid(this.value, 'abc123', JWPSCV_FROMLIST);"> Replace 'abc123' with only those characters you want to be allowed, and that should do it. If it happens to not work that way, try: <input type="text" onKeyUp="v=this.value;if (!JWPStringContentValid(this.value, 'abc123', JWPSCV_FROMLIST)){this.value=v;}"> Only slightly more effort that way :) Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Tue, June 27, 2006 1:41 pm, Monkeyden wrote: > 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] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]