1, the authentication method Validationnumber (E, num) e is the label object, and Num stands for the number of decimal digits.
function Validationnumber (e, num) {
var regu =/^[0-9]+\.? [0-9]*$/;
if (E.value!= "") {
if (!regu.test (E.value)) {
alert ("Please enter 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, verify the integer
<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 a 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. Keep two decimal digits
<asp:textbox id= "Txtstdyr" name= "Txtstdyr" runat= "Server" height= "16px" width= "98px" font-size= "9pt"
CssClass = "Edittextbox" onpropertychange= "Validationnumber (this,2)" ></asp:TextBox>
5. Keep three decimal digits
You only need to change the second argument in the Validationnumber (this,3) method to 3.
Keep Four decimal places, keep five decimal digits, etc. ...
Above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if there are questions you can message exchange, but also hope that a lot of support cloud Habitat community!