I have code that adds leading zero’s to a currency field. I require the total digits/chars to be 9 (inclusive of the decimal point.
for instance 1441.34 becomes 001441.34
The code works well for for values in the thousands/10’s of thousands/100’s of thousands but adds an additional decimal point when converting values of less than 1000
for instance 40.50 becomes 0.0040.50
for instance 138.00 becomes .00138.00
I’m sure it’s something simple…could someone point me in the right direction?
The code I’m using is as follows:
var val2 = record.fields[“Total”];
val2 = val2.replace(/[^0-9.]/g, “”);
var t = “000000.00” + val2;
result2 = t.substr(t.length-9);