Skip to main content
Participant
May 22, 2025
Question

Validate only calculate if any of these fields have data

  • May 22, 2025
  • 2 replies
  • 300 views

Long time user and forum follower. I've gotten help off here several times, but first time posting. We have a form in the Army to write up faults. I changed it to auto calculate money, manhours, etc. I've created it with 3 pages in case we have to write more stuff up. I have each totals calculating total from page 1 + total page 2 etc. Is there any way to validate the next page will only calculate if data is put in any of the fields on page 2? In other words no total will auto calculate on page 2 and page 3 unless a field is filled on page 2. Like if data is in "field1" or "field2" or "field3" etc then it'll begin calculating that page. Have attached screenshots of 2 of the pages. 

2 replies

Thom Parker
Community Expert
Community Expert
May 22, 2025

Yes.  The script in the calculations that need to be blocked can be setup to test for valid values in other fields before proceeding. 

 

For example, if the field that needs to be checked is named "Data1", then the calculation script that needs to be validated would look like this:

This code proceeds with the calculation only if the value in the Data1 fields is not empty and a number value. 

var strChkValue = this.getField("Data1").valueAsString;
if((strChkValue != "") && !isNaN(strChkValue)) 
{
   ... Do calculation.. 
   event.value = ...something...;
}

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
PDF Automation Station
Community Expert
Community Expert
May 22, 2025

You don't say what the field names are, how they differ from page to page, if at all, and what type of calculation you are using.  This might help you:

https://pdfautomationstation.substack.com/p/another-method-for-calculation-vs

Participant
May 22, 2025

I stated I have the totals carrying down from page to page + whatever the totals are on that page. I attached pictures of the form and set examples of "field1" "field2" etc. I can change the names of the fields in the code.