Regular Expression (Regex) for number with two decimal points in ASP.Net RegularExpression Validator

Last Reply on Jun 28, 2014 12:22 AM By Mudassar

Posted on Jun 28, 2014 12:22 AM

Restricting input to textbox: allowing only numbers and after input number allow one dot and after dot allow two number. 

Posted on Jun 28, 2014 12:22 AM

This way

  <asp:TextBox ID="TextBox1" runat="server" />
    <asp:RegularExpressionValidator ID="Regex1" runat="server" ValidationExpression="(?:\d*\.\d{1,2}|\d+)$" ErrorMessage = "Please enter valid decimal number with 2 decimal places."
        ControlToValidate="TextBox1" />
    <asp:Button Text="Validate" runat="server" />

Regex Ref: http://stackoverflow.com/questions/468655/javascript-decimal-place-restriction-with-regex

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html