This article mainly introduces jquery to determine the decimal point two digits and automatically delete decimal two digits after the number, the need for friends can refer to the following
jquery to determine the decimal point two digits and automatically delete decimal two digits after the number Basic is that the input 12.235689741 will be converted to 12.23, will not be rounded The JavaScript basics should be able to read it. does not explain code as follows: $ ("#fileds"). Find ("Input"). blur (function () { var value=$ (This). Val (); if (value = NULL | | value = =) { return false; } if (!isnan (value)) { VA R userreg=/^[0-9]+ ([.] {1} [0-9] {1,2})? $/; if (userreg.test (value)) { if (parseint (value). toString (). length > 5) { $ (this). Val (""); Alertmsg ("The entered integer must not be greater than 5 digits"); return false; } }else{ var numindex = parseint (Value.indexof ("."), 10 ); if (Numindex = = 0) { $ (this). Val (""); alertmsg ("the number entered is not canonical"); return false; } var Head = value.substring (0,numindex); var bottom = value.substring (numindex,numindex+3); var fianlnum = head+ bottom; $ (this). Val (fianlnum); } }else{ $ (this). Val (""); alertmsg ("Please enter a number"); return false; } }); &nbsP