Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
hi,

I have a Gridview with a textbox. How to limit number length before and after the decimal point in textbox keypress event . I want maximum 6 numbers before the decimal point and two number after the point . How to solve it with javascript/JQuery.

Please help me..

Thanks in advance..

Vineetha
Posted

1 solution

I think you should use Regular Expression,
i.e

XML
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator
        id="RegularExpressionValidator1"
        runat="server"
        ControlToValidate="TextBox1"
        ValidationExpression="^[0-9]{1,6}(\.[0-9]{0,2})?$"
        ErrorMessage="Invalid Number" />Invalid number</asp:RegularExpressionValidator>
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900