Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a asp.net regularexpressionvalidator ValidationExpression that will prevent to give input ; and –- .

I can do for – and it is ValidationExpression="[^-]*"
ASP.NET
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="**" 
            ValidationExpression="[^-]*"  >


Above expression can prevent single – character. I will give permission for single – chareter. I will block for double – character (--).
I need to prevent ; and – at a time.



block: ;.......--
:;......-
allow:....-

Can anyone help me?
Posted
Updated 11-Oct-11 9:00am
v2

1 solution

Try this out
C#
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="**" 
            ValidationExpression="^[--;-]$"  >
 
Share this answer
 
v2

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