The Acrobat Users Forum gets a lot of questions about the error message above. [Result] in the message is the name of the field causing the error. It usually occurs because the field is formatted as a number and a calculation is forcing a value into the field that is not a number.
Assume the Result field is formatted as a percentage. Also assume there are two other fields named A and B, and Result has the following simplified field notation:
This means Result is calculated as the value of field A divided by the value of field B. To write this formula as a script instead, enter the following as a custom calculation script:
event.value = this.getField("A").value / this.getField("B").value;
Entering anything but numbers into field A or field B will cause a formatting error. If fields A and B are formatted as numbers, that's all that can be entered so this can't be the issue.
As soon as a number value is entered into field A the error will message will pop up.
Why?
The different options in the format tab of the field properties (numbers, dates, etc.) actually contain a format script and a keystroke script which the form developer does not see. I wrote a few articles about how to program field formats with a script.
Calculations run every time a field value changes.
When a number is entered into field A the calculation in Result runs, dividing the value of field A by zero (the value of B is null and is interpreted as zero in a math calculation). To find out the result of [a number]÷0, run the following script in the console:
10/0
//The script above should return Infinity
A number divided by zero returns Infinity in JavaScript. Forcing Infinity into a field that is formatted as a number will cause the formatting error displayed at the beginning of this article.
Another way to see the result is to remove the number formatting from the field causing the error (Result in this case) and rerun the calculation by changing the value of any field. The Result field should display Infinity.
Removing the number formatting from the field displayed in the error message is the first step in troubleshooting this error because there could be other results that cause this error. Another one is NaN, which I will discuss next week.
The Solution
The solution to avoid this formatting error when using division in a math calculation is to write a custom calculation script that only runs if the value of the field representing the divisor has a value:
if(this.getField("B").value)
{event.value=this.getField("A").value/this.getField("B").value}