jquery determines the number of decimal points two digits and automatically deletes decimal two digits
Basically, enter 12.235689741
It's going to be 12.23, not rounded up.
The JavaScript basics should be visible.
Do not explain
Copy Code code as follows:
$ ("#fileds"). Find ("Input"). blur (function () {
var value=$ (this). Val () ;
if (value = NULL | | value = =) {
return false;
}
if (!isnan (value)) {
var userreg=/^[0-9]+ [.] {1} [0-9] {1,2})? $/;
if (userreg.test (value)) {
if parseint (value). toString (). length > 5) {
$ (this). Val ("");
alertmsg ("the integer entered 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 specification");
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;
}
});