Follow by Email

Thursday, August 29, 2013

Allow only decimal and float values in using asp RegularExpressionValidator control | Regular expression to validate float and decimal values example

Hi in this post i will show how to allow only decimal and float values in using regular expression.

In Aspx:

<asp:TextBox ID="txtEmpSalary" runat="server"></asp:TextBox>

<asp:RegularExpressionValidator ID="ValidateTotalBillAmount" ErrorMessage="Enter Proper value" ControlToValidate="txtEmpSalary" ValidationExpression="(?<=^|)\d+(\.\d+)?(?=$|)|(?<=^| )\.\d+(?=$|)" runat="server">

In code-behind:

 if (Page.IsValid = = false)

if page has any error then it will return.