These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Reset Button Returning Format Error Message for Form Field

dapike
Registered: Jun 24 2010
Posts: 11

I have created a form that does simple addition, subtraction and division calculations. Everything seems to be calculating just fine. When I click the Reset Button, all fields are reset 0, but it returns the error message: "Warning: JavaScript Window- The value entered does not match the format of the field [BreakevenPricePerBushel]."

The value "BreakevenPricePerBushel" is derived from "TotalExp / YieldPerAcre" (using Simplified Field Notation).
The value "TotalExp" is derived from a sum of the selected expense fields in my form.
The value "YieldPerAcre" is a number entered by the user.

The format for all fields:
Decimal Places: 2
Dollar Amount Fields: Currency Symbol
Default Value: 0.00

I can't say that I've done a zillion forms in Acrobat, but I have never had this happen before and I'm stumped. Any guidance would be greatly appreciated.

--DP

(my version # of Acrobat Pro is actually 9.3.2)

dapike

My Product Information:
Acrobat Pro 9.3.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
My guess is clearing the form is causing a division by zero.

George Kaiser

dapike
Registered: Jun 24 2010
Posts: 11
I have read about that in researching the error message on the Web, but have not been able to understand how to avoid or resolve it. Guess I'll take a break and go mow some lawn for a while... at least I understand how to do THAT :(

dapike

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Don't set the default value of YieldPerAcre to 0, or instead of the simplified notation, write a script that does the same, unless YieldPerAcre is 0.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Without knowing whether you are using Acrobat Forms Tools or LiveCycle Designer and field names, we can not provide exact code. As noted you will need to write a script that includes the use of the conditional execution statement 'if' which will test to see if your divisor is zero. If not zero then the division is executed, if zero you can do nothing, or set the field to 0 or a null string. The syntax of the 'if' statement is different in JavaScript and different in FormCalc.

George Kaiser

dapike
Registered: Jun 24 2010
Posts: 11
I am using the Forms Tool in Acrobat 9. I am ashamed to admit that JavaScript has never been my strong suit. I did have a class in it and I really struggled. I just want to understand! Are there any good 'real world' references out there that go beyond "Hello World" so I can finally begin to grasp this?

My sheepish apologies to try67; I see that that is the first thing I see when I go to your custom made scripts website. I certainly meant no offense. I will look thru that more closely and see if I can make some sense of it. TIA, both of you, for your patience!

dapike

dapike
Registered: Jun 24 2010
Posts: 11
For the time being, I am setting the default value of 1 to YieldPerAcre. This is acceptable to the form's creator, and looks a little more professional and less confusing to the user who sees the pop-up error window. At least it can buy me some time while I try to figure this out. Thanks!

dapike

try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can use this as BreakevenPricePerBushel's custom calculation script:
var TotalExp = this.getField("TotalExp").value;var YieldPerAcre = this.getField("YieldPerAcre").value; if (TotalExp!=null && TotalExp != "" && YieldPerAcre != null && YieldPerAcre !="" && YieldPerAcre != 0 ) {event.value = Number(TotalExp) / Number(YieldPerAcre);} else event.value = "";

If either of the two fields is empty, or if YieldPerAcre is zero, it will set the field to be empty. Otherwise, it will perform the calculation.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi dapike,

If you are looking for training specifically in Acrobat JavaScript you may want to visit www.pdfscripting.com and look around at the training resources available there ( a full series of Beginning Acrobat JavaScript training videos plus lots more). It's not free but is a "real world" reference library on the subject.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You could use the following custom calculation script for the Breakeve Price per Bushel.
// custom calculation script for BreakevenPricePerBushle field// setup some variables for field values/*assuming the total expense has been calculated and

the result is in a field named TotalExp

*/
var nTotalExp = this.getField('TotalExp').value;// force to numbernTotalExp = Number(nTotalExp);/*yield per acre value from a field called 'YieldPerAcre'

*/
var nYieldPerAcre = this.getField('YieldPerAcre').value;// force to numbernYieldPerAcre = Number(nYieldPerAcre);/*create a variable for the computed value

break even price per bushel

*/
var nBreakevenPricePerBushel = 0; /*If nYieldPerAcre is not zero or null computethe break even price per bushel*/if(nYieldPerAcre != 0) {nBreakevenPricePerBushel = nTotalExp / nYieldPerAcre;}// set the value for the field BreakevenPricePerBushelevent.value = nBreakevenPricePerBushel;

George Kaiser