Skip to main content
mariej97441354
Participating Frequently
July 11, 2017
Answered

The value entered does not match the format of the field

  • July 11, 2017
  • 1 reply
  • 7889 views

I have set up some basic formulas in my PDF.  Example....I have a Swing field and a Cycles field.  In the Cycles field under calculate I have a Simplified field notation:  (60*60)/Swing  The formula works fine but I have to have a number in Swing or it gives me a The value entered does not match the format of the field [Cycles]  - the format in Cycles is set up as a Number.  What do I need to change to be able to have a blank in Swing?

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

JavaScript for Acrobat is not the same as JavaScript for the web - that makes it a bit harder to find a good resource. Take a look here for a book that is dedicated to Acrobat's JavaScript: Beginning JavaScript for Adobe Acrobat

Here are some general resources: Learning to Program JavaScript for Adobe Acrobat - KHKonsulting LLC

Then, once you are familiar with JavaScript, you need to work with the Acrobat JavaScript documentation in the Acrobat SDK.

The "Maximum" field should be fine, but take a look at the script for Efficiency, and convert that to something similar to what I presented above.

1 reply

Karl Heinz  Kremer
Community Expert
Community Expert
July 11, 2017

When there is no value in the "Swing" field, the value returned for an empty string is 0, which means you are dividing by zero - which results in "NaN" - or "Not a Number". This is - as the name suggests - not a number, and therefore does not fit into the number format that you associated with the field. There are two ways around this: You can either use a custom formatting script for your result field, or you can use a custom calculation script that will not perform the calculation when there is no valid number in the "Swing" field. I would go with the second route. Something like this should work:

var f = this.getField("Swing");

if (f.valueAsString != "") {

  event.value = (60*60)/f.value;

}

else {

  event.value = "";

}

mariej97441354
Participating Frequently
July 11, 2017

I think I'm finding my problem.  I am very inexperienced in JavaScript.  What I have done is convert an excel file to PDF and am trying to program 3 fields.  The first field will be filled in by the user with a number (however I want it blank to start).  I've labeled that Swing.  That will then calculate Cycles (60*60)/Swing.  The next field they will enter is labeled Bucket.  The field I call Maximum will calculate Cycles*Bucket.  Finally They will enter Volume in one field (named Volume) and Hours into another field (named Hours)  The final box is Efficiency, which calculates the total of Volume/Hours/Maximum.  I'm thinking I will need to write a custom calculation script for all 3 boxes or they will be off.  I plan to convert several things from excel to fillable pdf's and will need to learn how this works.  Is there a course you recommend?  Any help you can offer would be greatly appreciated for this form.  I have all the formula's working fine..but just can't clear all the boxes to start with a blank form.  

Karl Heinz  Kremer
Community Expert
Community Expert
July 12, 2017

Thank you both!  Karl, I still kept getting an error with yours (but the figures worked great!) however Try67's worked for me.  I can't thank you both enough!  You both are pro's at this.  I'm hoping to learn as much as I can.

I have one final PDF that I'm working on and have figured out pretty much the whole thing.  It is very similar to the first one that now works perfectly.

My second one has almost the same format....3 boxes that are programmable based off entries.  I know I have the first box called Maximum computed properly.  My second box however is where I KNOW I need to put in JavaScript but I believe I am messing up on the formula.  This field takes the value of Maximum and multiplies that by the amount the user enters into Bucket then it divides that by what the user enters into Depth multiplied by Width and divides that total by 27.   example:  (Maximum*Bucket) / ((Depth*Width)/27)

This is what I have done so far:

var Bucket = Number(this.getField("Bucket").valueAsString);

var Depth = Number(this.getField("Depth").valueAsString);

var Width = Width(this.getField("Width").valueAsString);

var Maximum = Maximum(this.getField("Maximum").valueAsString);

I'm thinking the next line would be:

if (Width!=0 && Maximum!=0) event.value = (Maximum*Bucket)/Depth*Width)/27;

else event.value = "";

BUT....I'm getting a SyntaxError. 


There is a problem in this line:

event.value = (Maximum * Bucket) / Depth * Width) / 27;

The number of opening "(" and closing ")" does not match - they have to always be in pairs. I assume you want this:

event.value = (Maximum * Bucket) / (Depth * Width) / 27;