I had always used to ajaxToolkit MaskedEditExtender for entering decimal value. But I was interested to do the other way round without using ajaxToolkit MaskedEditExtender. Finally I found the solution using Regular Expression. I wanted 4 digit before decimal point and 3 digits after decimal point. Below is how I did it:
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator id="RegExVal" runat="server"
ControlToValidate="txtAmount" ValidationExpression="^[0-9]{1,4}(\.[0-9]{0,3})?$"
ErrorMessage="Enter Exact decimal value" />
Happy coding... :)
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator id="RegExVal" runat="server"
ControlToValidate="txtAmount" ValidationExpression="^[0-9]{1,4}(\.[0-9]{0,3})?$"
ErrorMessage="Enter Exact decimal value" />
Happy coding... :)
Comments
Post a Comment