What shoul happen if only one or two digits are entered?
If the result needs to be $0.03 and the user only enters the 3, I need that to be placed in the far right slot so it will be $0.03. If the result needs to be $0.23 and the user only enters 23, I need that placed in the two right slots so it will be $0.23. It would be HIGHLY unlikely that the first slot to the left of the decimal would ever be anything other than 0, so I'm not even worried about that slot. If the $0. could be set in place and have the user only enter the two digits on the right, that would be great too.
I think the simplest approach is to use a custom Validate script for the field, something like:
if (event.value) event.value = util.printf("%.2f", event.value / 100);
On the Options tab of the Field Properties dialog, set the character limit to 3, and set the Format to 2 decimal places with the dollar sign.
if (event.value) event.value = 1 * util.printf("%.2f", event.value / 100);
There's no need to do that when setting the field value, which is what this Validation script does. It's always a good idea to explicitly convert to a number when getting the field value for use in a calculation script, especially if it will be used for numeric addition.
I'm still having problems. I've tried many things and both of the codes above but I'm still not getting it right for some reason.
These are the names of the fields: ADD Rate, Benefit Amt, 64, 65, 70.
I need ADD Rate to be a 3 digit number in this format $x.xx
I need Benefit Amt to be a maximum of 6 numbers in this format $xxx,xxx
I need field 64 to be ADD Rate x Benefit Amt x 0.001 --- in format $x.xx
I need field 65 to be field 64 x 0.65 --- in format $x.xx
I need field 70 to be field 64 x 0.50 --- in format $x.xx
I just can't get it in the right format or something.
I've limited the number of digits and set it to two decimal places on the fields that need it.
But I'm just not getting it.