Number validation in Textbox of ASP.NET Using Regular Expression validator

some time we require Only numbers can be enter by user into a Textbox for that We can use Regular expression validator in for this:
In the validation expression property keep ^\d+$.

<asp:TextBox ID="txtnumber" runat="server" ValidationGroup="number"></asp:TextBox>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtnumber"
ErrorMessage="Please Enter Only Numbers" ValidationExpression="^\d+$" ValidationGroup="number"></asp:RegularExpressionValidator>

Tags: , , ,

Join Us!