Javascript input Validation

THT

THT

Associate
Joined
10 Mar 2004
Posts
998
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?
 
yeah you can use the onkeypress event

Its just I dont want to have to specify every character im allowing

A-Z 0-9 ,.><??'@;{[}]#~

Theres a lot of punctuation characters which I want to allow.... just not the foreign characters
 
Thanks Rob,

I need to know if theres a way (or maybe the actual regexp?) for english chars only with punctuation.

Excluding things like Ĉ è æ ....
 
Back
Top Bottom