I have tried adding dropdown lists to the following check without success

New Here ,
Apr 24, 2019 Apr 24, 2019

Copy link to clipboard

Copied

Hi

I have the following javascript in a button before a form is ready for signature which is working, which I have found on various forums. However, I need to include 2 more items

1) to include checks on dropdown lists if they are visible and required, the default value of these dropdown lists are "SELECT ITEM",

and

2) if possible I would like to have an additional message displayed if a certain checkbox called divur1 is not ticked before displaying the main message which is included in my script below

var emptyFields = [];

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

     var f= this.getField(this.getNthFieldName(i));

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

          if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

     }

}

if (emptyFields.length>0) {

     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));

} else {

// actions to complete when all required fields completed.

app.alert("Congratulations, all fields completed, Choose your name below and Digitally sign the form. DID THE CUSTOMER AGREE TO MARKETING EMAILS IF YES PLEASE CHECK THE BOX UNDER CONTACTS IS TICKED otherwise continue");

}

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

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

125

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , Apr 24, 2019 Apr 24, 2019
1. Change this line:if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);To:if (f.display==display.visible && f.valueAsString==f.defaultValue) emptyFields.push(f.name);2. Add this to your code:if (this.getField("divur1").valueAsString=="Off") app.alert("Some error message.");

Likes

Translate

Translate
Adobe Community Professional ,
Apr 24, 2019 Apr 24, 2019

Copy link to clipboard

Copied

1. Change this line:

if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

To:

if (f.display==display.visible && f.valueAsString==f.defaultValue) emptyFields.push(f.name);

2. Add this to your code:

if (this.getField("divur1").valueAsString=="Off") app.alert("Some error message.");

Likes

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
New Here ,
Apr 24, 2019 Apr 24, 2019

Copy link to clipboard

Copied

Hi

thanks it worked but now it is requiring all my radio buttons to be checked, how would I handle these as obviously they only require one choice and they are pre-checked on a standard

Likes

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

Not sure what you mean... If one of the radio-buttons is pre-selected, what is there to validate?

Likes

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
New Here ,
Apr 25, 2019 Apr 25, 2019

Copy link to clipboard

Copied

LATEST

You are right I made the radio buttons as not required and resolved the issue

Likes

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