tags:

views:

59

answers:

3

I want to add a validation control to check if the first name and last name of a person entered consists of characters from A-Z and not any special characters and numbers? How to do it?

A: 

You could use a Regular Expression validator or a Custom Validator.

Anthony
+1  A: 

use a regular expression validator and put the [a-zA-Z] as the reg ex to validate.
If you want support for hyphen and underscore then put [a-zA-Z_\-]

<asp:RegularExpressionValidator id="revalApha" runat="server" 
ControlToValidate="TextBox1" ValidationExpression="[a-zA-Z]+$" 
ErrorMessage="Only Alphabets allowed"> </asp:RegularExpressionValidator>

I will advice against the custom validator since you need to write a function both in javascript and in c#

Binoj Antony
A: 

Here is a good example of using a regular expression validator for that. But don't forget O'Dell and Van Damme. :)

JP Alioto