Click here to Skip to main content
15,924,367 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to know the regular expression for only alpha characters in C# code
Posted

You could have tried a Google search[^] first.
 
Share this answer
 
CSS
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="txtYourControlId"
                      ValidationGroup="ValidGroup" Display="Dynamic" ValidationExpression="^[a-zA-Z'.\s]"
                      Text="Please enter alphabets only" />


Use this : ValidationExpression="^[a-zA-Z'.\s]"
 
Share this answer
 
v2
you can use regular expression to do the same:

C#
//use System.Text.RegularExpressions

if (Regex.IsMatch("^[a-zA-Z]", textBox1.Text))
   {
//assign error to label
          }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900