6 Replies Latest reply on Oct 12, 2012 7:14 PM by Branchard0902

# Number Format Problem

Hi - I am fairly new to Adobe Acrobat 9 and have a question.

#1. I have a field named "Rate". The user needs to enter 3 digits and the format needs to come out as \$x.xx. But typically the first two digits they will enter are 00. Some examples of numbers that would be entered into this field would be: 003, 007, 010, 015, etc. Again, I need the format to come out at \$x.xx. This field will then be multiplied with another field for final results. I don't want the user to have to enter the decimal point for 0.03. I just want them to enter 003 and the field show \$0.03. Any suggestions?

Thanks,

Brandy

• ###### 1. Re: Number Format Problem

What shoul happen if only one or two digits are entered?

• ###### 2. Re: Number Format Problem

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.

• ###### 3. Re: Number Format Problem

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.

• ###### 4. Re: Number Format Problem

The JS will create a string and not a number. If the value is used in with JavaScript after this calculation it could cause a problem. Multiply by 1 or use the Number constrictor.

if (event.value) event.value = 1 * util.printf("%.2f", event.value / 100);

• ###### 5. Re: Number Format Problem

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.

• ###### 6. Re: Number Format Problem

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.

HELP!