Skip to main content
coryc34860424
Participant
April 9, 2018
Answered

Need help with "value entered doesn't match the format" in my PDF

  • April 9, 2018
  • 4 replies
  • 764 views

Need help with "value entered doesn't match the format" in my PDF.  This message pops up every time I tab to a new field when entering data.

This topic has been closed for replies.
Correct answer Test Screen Name

The message is correct. In arithmetic, blank is the same as zero. Division by zero is impossible. Instead of crashing it creates a special result which is Not A Number.

You must write code to check the value before you divide by it.

4 replies

coryc34860424
Participant
April 10, 2018

I found the solution.  Thanks!

coryc34860424
Participant
April 10, 2018

Here is my formula:

event.value = (this.getField("Text2").value - this.getField("FROM_2").value) / this.getField("FROM_2").value;

Lines "Text2" and "FROM_2" are blank until the information is filled in by the employees and also formatted as a percentage.

I keep getting the error

try67
Community Expert
Community Expert
April 10, 2018

As I thought, you're diving by a value of a field.

Change your code to:

if (Number(this.getField("FROM_2").valueAsString)==0) event.value = "";

else event.value = (this.getField("Text2").value - this.getField("FROM_2").value) / this.getField("FROM_2").value;

Thom Parker
Community Expert
Community Expert
April 9, 2018

The problem, as stated in the messages, is that the value of a field doesn't match the stated formatting. This happens most often with calculated fields that have a number format, where the calculation turns out to be something other than a number. Usually because of missing data.  

Here's what you do. Remove the formatting from each field one at a time until the message goes away. Then examine the field to determine what is causing it to produce the message.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
April 9, 2018

My guess is you have a script that uses division and the divisor is the value of another field. When that field is blank (or zero) the result is an illegal operation. Try searching the forums for division scripts. This issue was discussed many times in the past.