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

Problem with formula in Acrobat Form - NEED HELP FAST

milodog
Registered: May 30 2009
Posts: 22

I have a formula (in field G1) that divides 2 fields (D1/B1). The formula works fine, however, when I delete the data in either of the 2 fields (or retype over it), I get an error message that states "The value entered does not match the format of the field G1". This formula is in 6 other rows below it (i.e., G2, G3, G4, etc.) with the correct fields in the equation (D2/B2, D3/B3, etc). I need to not get this error message when I retype or delete numbers in these fields as it is a fillable form that will have different data in it depending on certain factors.

Can someone help me please? I would greatly appreciate it. Please note that I do not know Javascript and with whatever solution you present please keep this in mind (to save time).

Thanks!!

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You are dividing by zero!

Change the format for field 'G1' from "Number" to 'None" andd observe what happens as you clear the form and enter in various values including zero.

You will need to provide control code that prevents the divison or traps the unwanted results.

You can either write a 'Custom calculation script' or a 'Custom vailidation script'.

George Kaiser

milodog
Registered: May 30 2009
Posts: 22
Can you give me the code that prevents the division or traps the unwanted results? I don't know Java.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
For your 'G1' 'Custom calculation script':

// clear field valueevent.value = '';// perform division only if divisor is not zero or nullif(this.getField('D1').value != 0)event.value = this.getField('D1').value / this.getField('B1').value

I'll let you figure out the code for the other fields.

George Kaiser

milodog
Registered: May 30 2009
Posts: 22
Am I supposed to put that in the Custom Calculation Script? That's were I put it, but I get .91533333. Is there any way there can be code that rounds up to only 2 decimal places? Thank you so much for your help!!
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Since you have been able to avoid the none numeric values, you can set the field format to "Number" with the optional parameters as needed.

Acrobat uses JavaScript and not the Java language.

George Kaiser

milodog
Registered: May 30 2009
Posts: 22
When I change is back to number I get the same error message as previously (The value entered does not match the format of the field G1). In other words I'm back to square one when I do this.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Sorry,

The code should read:

// clear field value
event.value = '';
// perform division only if divisor is not zero or null
if(this.getField('B1').value != 0)
event.value = this.getField('D1').value / this.getField('B1').value;

George Kaiser

milodog
Registered: May 30 2009
Posts: 22
You are GREAT!! This seems to work. I need to copy the formula down to the rows beneath it and change the field names in the formulas, but I don't anticipate a problem. I'll let you know if I do.

Thanks so much!!
milodog
Registered: May 30 2009
Posts: 22
No more problems occured when I copied the formula down. Thanks again!!