I created a bunch of forms with fields using the Number selection from the Format tab and thought everything was fine, but have now realized that small rounding errors accumulate, and the end result might be wrong by one or two cents.
On the first form that I’m trying to correct, I have set the Format category to None, and now need to include the $ money sign, the comma separator, and two places after the decimal point. From someone else’s post, in order to include two places after the decimal point, I’ve included in the Run Custom Validation Script:
Is this OK to use, or will this also create problems?
It should be fine. If a problem does arise one could force the value of the field to a number by using the Number constrictor.
event.value = Number(util.printf("%.2f", event.value));
You will need to use some additional code if you want to do not want to display 0.00.
There are other more sophisticated methods of rounding values than the printf method.