Monday, May 17, 2021

Regex to allow integer as well as decimal digit(4 decimal)


 ^[1-9]\d*(\.\d{1,4})?$

here you have to keep  number of decimal points to allow.

 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Amount in decimals is not allowed" ControlToValidate="txtAmount_value" ValidationExpression="^[1-9]\d*(\.\d{1,4})?$" Display="Dynamic"></asp:RegularExpressionValidator>