Skip to main content
Participant
November 30, 2018
Answered

Required Fields

  • November 30, 2018
  • 14 replies
  • 5061 views

Error: At least one required field was empty. Please fill in the required fields (highlighted) before continuing

I have removed all of the required fields in my pdf but I am still getting this error. Is there a way to search for a required field that may be hidden?

This topic has been closed for replies.
Correct answer George_Johnson

Execute the following code in the interactive JavaScript console (Ctrl+J):

for (var i = 0; i < numFields; i += 1) {

    var f = getField(getNthFieldName(i));

    if (f && f.type !== "button" && f.required && !f.valueAsString) {

        console.println("Name: " + f.name + "\tType: " + f.type + "\tPage: " + f.page);

    }

}

If it indicates a field with a page of -1, it's on a hidden template.

14 replies

Known Participant
May 14, 2019

I assume you mean the fields that I wish to hide/unhide. These are text fields and can also be a drop down.

Bernd Alheit
Community Expert
Community Expert
May 14, 2019

I mean the field with the calculation script.

Known Participant
May 13, 2019

In Calculate tab, Custom Calculation script.

Bernd Alheit
Community Expert
Community Expert
May 13, 2019

What values does you use in the field?

Known Participant
May 13, 2019

Hi

The if condition is not the issue as it was a representation, however the actual code is :

//start of script

this.getField("PARTNER").required = (event.target.value!="Off");

this.getField("PARTNER").display = display.hidden;

if (event.value == "INDIRECT")

  {

   this.getField("PARTNER").display = display.visible;

   this.getField("PARTNER").required = (event.target.value!="On");

}

Bernd Alheit
Community Expert
Community Expert
May 13, 2019

Where does you use this script?

Known Participant
May 13, 2019

Thank you for the replies.

From my investigation, I need to know how can I switch fields mandatory or not based on other field selections.

Thank you

J

Legend
May 13, 2019

Be sure to SELECT all of the script before you execute it, otherwise it only does the current single line. Weird editor.

Known Participant
May 13, 2019

My issue at the moment is as follows :

The form based on certain field values displays or hides other fields. I use the following to hide/un-hide and make fields mandatory.

//start of script

this.getField("PARTNER").required = (event.target.value!="Off");

this.getField("PARTNER").display = display.hidden;

If condition true

   this.getField("PARTNER").display = display.visible;

   this.getField("PARTNER").required = (event.target.value!="On");

When I submit the form, it gives the error of

I have manually gone through all the fields and un-selected "required" in the general tab, and this seems to work, however I need to ensure that based on key field values the information that is mandatory is filled before submitting.

Kindly advise.

Thank you

Bernd Alheit
Community Expert
Community Expert
May 13, 2019

The following is not Javascript:

If condition true

Known Participant
May 13, 2019

I can now enter the script, however the result is "undefined" as per below.

try67
Community Expert
Community Expert
May 13, 2019

"undefined" just means the script completed executing. It seems that no fields were found that match the criteria you specified.

Known Participant
May 13, 2019

That worked. Thank you.

Known Participant
May 13, 2019

It does not allow me to type in any of the fields.

Bernd Alheit
Community Expert
Community Expert
May 13, 2019

Repair your Acrobat installation.

Known Participant
May 13, 2019

This is the screen with the debugger. Where should I enter the script as it does not allow me to type anywhere.

Thank you

Bernd Alheit
Community Expert
Community Expert
May 13, 2019

What happens when you type in the field at the bottom?