Number Validation in Textbox of ASP.NET Using Regular Expression Validator

Below is a simple example of Number Validation in Textbox of ASP.Net Using Regular Expression Validator. 
It will also allow all decimal number, excluding all alphanumeric characters.

<asp:TextBox ID="AssetsTextBox" runat="server" Width="240px"></asp:TextBox>                               
                                
<asp:RegularExpressionValidator ID="revAssets" runat="server" 
ErrorMessage="Assets must be a number" Font-Bold="False" 
Font-Size="Small" 
ValidationExpression="^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$" 
ControlToValidate="AssetsTextBox" Display="Dynamic" >
</asp:RegularExpressionValidator>

No comments:

Post a Comment