Creating a conditional action with multiple required fields

New Here ,
Apr 23, 2019 Apr 23, 2019

Copy link to clipboard

Copied

I'm new at this and I'm currently working on a document in Acrobat Pro DC where I want to have a portion of the document hidden until all of the required fields are filled with any value.

So far, I've only found resources on how to use a check box (or something similar like a button) to hide/show the additional portion of the document. This is what I'll end up doing as a last resort, but it's not ideal since the user will be able to toggle it on/off at any time, and my preference is for them to be able to do so only after all the fields are filled out.

My basic understand from using IF AND statements in Excel leads me to believe that should is a relatively simple script, but I haven't found any tutorials or examples of this scenario using JavaScript in Acrobat Pro DC. So any resources you can point me to would be appreciated!

TOPICS
Acrobat SDK and JavaScript

Views

189

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 24, 2019 Apr 24, 2019

Copy link to clipboard

Copied

The state of the"required" fields can be detected with a calculation script. Calculation scripts are run any time any field on the form is changed. I'm not sure what you mean by "required", so for the example code I'll use a list of field names.

Put this code in to a calculation script in any field on the form that is not already doing a calculation. You could even create a hidden field for this purpose.

var aFields = ["Field1", "Field2", "Field3", ...etc...];

var bAllFilled = true;

for(var i=0;i<aFields.length;i++)

{

    var oFld = this.getField(aFields);

     if(oFld.value == oFld.defaultValue)

     {

          bAllFilled = false;

          break;

      }

}

if(bAllFilled)

{

   ... Code for showing other part of form ...

}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines