1. Verification Method Validationnumber (E, NUM) e represents the Label object, and Num represents the number of decimal digits reserved
function Validationnumber (e, num) {varRegu =/^[0-9]+\.? [0-9]*$/; if(E.value! ="") { if(!regu.test (E.value)) {Alert ("Please enter the correct number"); E.value= E.value.substring (0, E.value.length-1); E.focus (); } Else { if(num = =0) { if(E.value.indexof ('.') >-1) {E.value= E.value.substring (0, E.value.length-1); E.focus (); } } if(E.value.indexof ('.') >-1) { if(E.value.split ('.')[1].length >num) {E.value= E.value.substring (0, E.value.length-1); E.focus (); } } } } }
2. Verifying integers
<asp:textbox id="txtng"Name="txtng"runat="Server"height="16px"Width="98px"Font-size="9pt"CssClass="Edittextbox"Onpropertychange="Validationnumber (this,0)"></asp:TextBox>
3. Keep One decimal
<asp:textbox id="Txtchglinecost"Name="Txtchglinecost"runat="Server"height="16px" Width="98px"Font-size="9pt"
cssclass="Edittextbox"Onpropertychange="Validationnumber (this,1)"></asp:TextBox>
4. Retain two decimal places
<asp:textbox id="Txtstdyr"Name="Txtstdyr"runat="Server"height="16px"Width="98px" Font-size="9pt"
cssclass="Edittextbox"Onpropertychange="Validationnumber (this,2)"></asp:TextBox>
5. Retain three decimal places
You only need to change the second parameter in the Validationnumber (this,3) method to 3.
Keep Four decimal places, keep five decimal places, etc...
Verify that the input is numeric, fractional, and contains several decimals reserved