Wednesday, 30 January 2013

Telerik RadmaskedTextbox validation experssion for Phone Number that doesn't allow zero at start and not all digits zero in ASP.NET




Validation expression for Phone Number for the mask="(###)###-####"


Here is the Source Code:

<telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Label="PHONENUMBER:"Mask="(###)###-####"></telerik:RadMaskedTextBox>

<asp:RequiredFieldValidator Display="Dynamic" ID="MaskedTextBoxRequiredFieldValidator"runat="server" ErrorMessage="Please, enter a phone number." ControlToValidate="RadMaskedTextBox1"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator Display="Dynamic" ID="MaskedTextBoxRegularExpressionValidator"runat="server" ErrorMessage="Incorrect Format"ControlToValidate="RadMaskedTextBox1"

ValidationExpression="^[\( ][0-9X][1-9][0-9][\) ]?[0-9]{3}[\- ]?[0-9]{4}$">
</asp:RegularExpressionValidator>