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?
vb9666Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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;
}
else
{
    event.value = "";
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.