Take the 2-minute tour ×

Do I need to use regex to ensure that the user has typed in English? All characters are valid except non English characters.

How do I validate this textbox?

share|improve this question
"English characters" is an ambiguous specification. Is "6" an "English character"? What about "é"? (Before you say no, consider words like café, resumé, fiancé, et cetera.) You're going to need to be more specific. –  John Feminella Jan 17 '10 at 15:41
its duplicate question you can get the answer here stackoverflow.com/questions/150033/… –  GuruKulki Jan 17 '10 at 15:43
Not only what @John Feminella already stated but also all the punctuation characters. Is such a symbol as "™" to be considered part of the English characters? –  Miguel Ventura Jan 17 '10 at 15:44
@John - For the purpose of validating this textbox, yes 6 is an English character. @Miguel - Yes TM is a valid character as well. –  Nick Jan 17 '10 at 16:25
add comment

3 Answers

A regex would work quite well for this. Something like

^[a-zA-Z0-9 ?!.,;:$]*$

would be a good starting point. It would allow all alphabetical and numerical characters, as well as some common punctuation. You would need to change it depending on what your definition of English characters is.

See the regex docs here for more information.

share|improve this answer
Good regex. Just to add, you could implement this regex using a RegularExpressionValidator and assigning the textbox as the 'ControlToValidate': msdn.microsoft.com/en-us/library/eahwtc9e(VS.71).aspx –  keyboardP Jan 17 '10 at 16:01
My definition of english characters are any english alphabets, numbers and symbols. Here's the context of what I am trying to do. I have an app that converts text to a different format. Currently, the plugin I am using supports only english. I need to validate before I pass this through the 3rd party component. –  Nick Jan 17 '10 at 16:32
In that case, I would go with Kibbee's answer :-) +1 to Kibbee –  IrishChieftain Jan 17 '10 at 17:18
@Kibbee - Would this regex accept or reject symbols such as Copyright, trademark etc? –  Nick Jan 18 '10 at 16:29
Yes it would. Basically, it only allows letters, numbers, space, and ? ! . , ; : You would have to alter it (refer to linked docs) to meet your specific needs. –  Kibbee Jan 19 '10 at 1:16
add comment

This has nothing to do with regular expressions and the link referred to by gurukulki does not answer the question either. To change language, you need to implement localization in your website:

http://www.west-wind.com/presentations/wwdbResourceProvider/introtolocalization.aspxlink text


share|improve this answer
add comment

You might use the FilteredTextBox form ASP.NET AJAX.

share|improve this answer
add comment

Your Answer


