Jquery determines the number after two decimal places and automatically removes two decimal places
- 2020-03-30 02:25:17
- OfStack
Jquery determines the number after two decimal places and automatically removes two decimal places
Basically, 12.235689741
It's going to be 12.23, it's not going to be rounded
Anyone who knows the basics of javascript should be able to see that
Don't explain
Basically, 12.235689741
It's going to be 12.23, it's not going to be rounded
Anyone who knows the basics of javascript should be able to see that
Don't explain
$("#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 input integer must not be greater than 5 digits ");
return false;
}
}else{
var numindex = parseInt(value.indexOf("."),10);
if(numindex == 0){
$(this).val("");
alertMsg(" The Numbers entered are irregular ");
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;
}
});