How to validate only characters will be allowed in Textbox?

 Posted by Rajesh_Kumar on 1/21/2014 | Category: ASP.NET Interview questions | Views: 1980 | Points: 40

We will use Regular Expression Validator control to validate Textbox.Below codd will allow only characters with no spaces.

<asp:TextBox runat="server" Id="txt_first_name" />

<asp:RegularExpressionValidator runat="server" id="rex_first_name" ControlToValidate="txt_first_name" ValidationExpression="^[a-zA-Z]$" ErrorMessage="Only Characters Allowed" />

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response