1

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

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

That totally did the job. Thnx!! :D
2

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

6 Comments

@Abhishek Simon couldnt set property to validator
@Ranhiru Cooray Thanks both of you it works perfectly but i found the need to also validate the "."and to accept the specials after the first is alphabetic
@vkline: I obviously cannot take any credit. All I did was just make the answer look prettier :) Glad you could find the answer :)
@Ranhiru Cooray But can you help me with my new problem :). I want this regex to not accept also .(dot) for first char and also after the first character is alphabetic those special chars to be accepted. cause at the monet C# doesnt semm to work. It accepts normally the dot and after the first char is alphabetic it doenst accept any special char.
@vkline: Does this work? ^[a-zA-Z'.\-\s\.]{1}$|^[a-zA-Z'.\-\s\.]{1}[\w+]*$
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.