Debt Consolidation - Debt Consolidation - Wordpress Theme - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Javascript Input Validation


THT
Feb 14th 2007, 1:16 am
I need to validate a Text box using javascript

Id like to do it on keypress so that if a user enters a character they shouldnt, it displays a message.

The only characters that should be allowed are A-Z 0-9 and all punctuation
Im trying to do this to avoid people entering foreign characters such as Ĉ è æ

Should I do this using a regular expression?
Whats the easiest way to do this?

designcode
Feb 14th 2007, 1:36 am
Read following tutorial, it will help you

http://home.cogeco.ca/~ve3ll/jstutore.htm

THT
Feb 14th 2007, 1:44 am
Ok, i knwo how regular expressions work

I just need to know if there is an easier way rather than specifying

[a-z][0-9] and then all the other special characters i want to allow.......


Can i just exclude foreign characters?

ajsa52
Feb 14th 2007, 3:21 pm
You can try with this: [\x20-\x7F] or the range you want from ascii table.