Print Page | Close Window

Validation script to clear field

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
Printed Date: 20 Nov 2019 at 8:12pm
Software Version: Web Wiz Forums 11.10 -

Topic: Validation script to clear field
Posted By: Scruffy
Subject: Validation script to clear field
Date Posted: 21 Aug 2015 at 8:20pm
I don't have knowledge in Javascript but I need to enter a validation script.  I have a PDF form with these three fields:

01a = quantity
01b = price
01c = calculated product of Fields A & B

I want the field 01b to be cleared when the value in the field 01a is removed. Putting the exact script below in the field 01b didn't work:


Please help.  Thank you.

Posted By: gkaiseril
Date Posted: 21 Aug 2015 at 9:21pm
The validation script for any field only executes when that specific field is updated either by user entered data or being populated by JavaScript. Since neither of these actions is done to this field, then you validation script does not run. I would look at using the validation or custom JavaScript calculation script for 01a with appropriate modifications for the location.

Posted By: Scruffy
Date Posted: 21 Aug 2015 at 10:16pm
Hi, gkaiseril.

Thank you for your reply but I am not sure what you mean (I am so embarrassed here but I don't know Javascript so it is a space language to me, lol.).

In my original post, I wrote

01c = calculated product of Fields A & B

but I should have said

 01c = calculated product of 01a and 01b

On the form there are many rows (looks like the one below) and each row has a specific product name.  When products are sold, values are entered in the applicable row. 

01a, 01b and 01c are on row 1.  When values are entered on the row 1 (01a and 01b), 01c calculates the amount.

Let's say I enter values on row 1 but later find out I entered the values on the wrong row.  I remove the value in 01a.  Then the calculated amount in 01c disappears but the value in 01b remains there (e.g. $20.00).   I want the value in 01b to disappear as well.

Thank you for your help.

Posted By: try67
Date Posted: 21 Aug 2015 at 11:15pm
So basically you want to clear 01b when 01a is cleared, right?
If so, use this script as the custom validation script of 01a:

if (event.value=="") this.getField("01b").value = "";

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Posted By: Scruffy
Date Posted: 21 Aug 2015 at 11:19pm
It worked like a magic!
Thank you!!!

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -