Tuesday, 3 July 2012


how to validate textbox only for number? and not allow empty


<asp:TextBox ID="txt_telephone" runat="server" ></asp:TextBox>

<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" Font-Size="10px" ControlToValidate="txt_telephone" Display="Dynamic" ErrorMessage="<br>Telephone Number must be 7-11 digit" ValidationExpression="^[0-9]{7,11}$"></asp:RegularExpressionValidator>

Validation expression ="^[0-9]{7,11}$" 

[0-9] - means it will take only 0 to 9 Numeric value 
{7,11} - means it will take number between 7 to 11 digit.

No comments:

Post a Comment