• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 993
  • Last Modified:

Conditional Calculation to prevent error

I have a textbox on my fillable adobe acrobat pro form that is causing errors.

The formula is something like this
(txtTextBox1 + txtTextBox2)/txtTextBox3

When the form is blank and there are no numbers I get an error that says "The value entered does not match the format of the field. Enter the fields with all valid numbers and then the errors stop.

I need to have a conditional formula that checks to see if the value of each textbox is greater than one before running the calculation and I believe that will fix the error. Does anyone know how to do this?
1 Solution
Karl Heinz KremerCommented:
THere are different ways to do a calculation in a PDF form. You are using the simple field notation, which does not provide you with a way to use error checking. You can also use a JavaScript calculation script that can do more than the "simple" calculation method - it can e.g. check for valid data before the calculation is performed. I assume that you have selected a number format for the input and output fields.

Try the following as the JavaScript calculation script:

var t1 = this.getField("txtTextBox1").value;
var t2 = this.getField("txtTextBox2").value;
var t3 = this.getField("txtTextBox3").value;

if (t1.toString().length > 0 && t2.toString().length > 0 && t3.toString().length > 0) {
    event.value = (t1 + t2)/t3;
    event.value = "";

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now