vkampouris
vkampouris

Reputation: 589

C# Regex Validator Validation

I have this

<asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server"    
     ControlToValidate="txtLastName"Display="Dynamic" ErrorMessage="Alphabetic characters only"
     ForeColor="Red" ValidationExpression="^[a-zA-Z'.\-\s]{1,50)$"
></asp:RegularExpressionValidator>

but now i want to change it and make a Regex that will let the user to insert 1 character but not one of the special chars in the expression above, nor to start with one of those special chars(also include "." spacial char".

NOTE : I want those specials to be accepted after the first char is alphabetic

thnx in advance

Upvotes: 1

Views: 1344

Answers (2)

Panagiotis Lefas
Panagiotis Lefas

Reputation: 1155

Try this [a-zA-Z][a-zA-Z'.\s\-]{0,50} :D //revised 1 to 0

Upvotes: 3

AabinGunz
AabinGunz

Reputation: 12347

Try this ^[a-zA-Z'.\-\s]{1}$|^[a-zA-Z'.\-\s]{1}[\w]*$

Upvotes: 2

Related Questions