function formatNumber(value, decimalPlaces) {
if(isNaN(value) || ""==value) {
value = 0;
}
value = parseFloat(value).toFixed(decimalPlaces);
return parseInt(value).toLocaleString().split(".")[0] + "." + value.split(".")[1];
}
Eg: 7389948 --> 7,389,948.00
If we want the reverse to happen ( 7,389,948.00 --> 7389948)
var a = receivedField.value.replace(/,/g, "");
if(isNaN(value) || ""==value) {
value = 0;
}
value = parseFloat(value).toFixed(decimalPlaces);
return parseInt(value).toLocaleString().split(".")[0] + "." + value.split(".")[1];
}
Eg: 7389948 --> 7,389,948.00
If we want the reverse to happen ( 7,389,948.00 --> 7389948)
var a = receivedField.value.replace(/,/g, "");
0 comments:
Post a Comment