views:

219

answers:

2

I want to allow only English characters to be typed in my asp:TextBox (in asp:Login conttrol).

How can I do that?

+1  A: 

You can achieve this using the FilteredTextBox.

It can also be done with plain javascript (FilteredTextBox also relies on javascript, but you can do it with only javascript that you write yourself) by registering an onKeyUp listener, and filtering out the characters that are not in an allowed subset (perhaps with a regex replace)

David Hedlund
+9  A: 

Use a RegularExpressionValidator control. There is a decent example here.

The regular expression for only English characters is ^[A-Za-z]*$

Fiona Holder