Common validation in ASP.NET

Just number and “-“, maximum length: 15

<asp:RegularExpressionValidator ID=”RegularExpressionValidator2″ runat=”server” ControlToValidate=”txtPhone”
                                ErrorMessage=”<%$ Resources:Errors, InvalidPhoneNumber %>” ValidationExpression=”^([0-9+\-]{1,15})” Display=”None” EnableClientScript=”false”

Valid email

<asp:RegularExpressionValidator ID=”vldEmail2″ runat=”server” ControlToValidate=”txtEmailAddress”
                ErrorMessage=”<%$ Resources:Errors, InvalidEmail %>” Text=”invalid email” ValidationExpression=”^([a-zA-Z0-9_’+\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9:]{2,4})+$”
                EnableClientScript=”False” Display=”None”  />


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: