• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adding Conditional Formatting so by choosing "No" in a radio button hides all fields

New Here ,
Feb 02, 2021 Feb 02, 2021

Copy link to clipboard

Copied

I am using a form and I have a radio button set to "hide" all fields if marked off as "No"

 

However, I am running  a script stating that if you choose "yes" all fields have to be filled in.

 

But even when the "no" is checked, the same fields are requiring to be filled out even though they are hidden.

 

// iterate over all fields and check the ones that are marked as 'required'

var valid = true;

for (var i=0; i<this.numFields; i++) {
    var f = this.getField(this.getNthFieldName(i));
    if (f.type != "button" && f.required) {
        // handle the differnet field types
        // valid types are button, checkbox, combobox, listbox, radiobutton, signature and text
        if (f.type == "text") {
            if (f.value == "") {                valid = false;
                break;
            }
        }
        else if (f.type == "combobox") {
            // handle the combobox type...
        }
        // ... handle all the other types
    }
}

if (valid == false) {    app.alert("Validation error. Some requried fields are not filled out!");
}
else {
    this.mailDoc();
}

 

 

My script is below, how do I add/adjust? 

TOPICS
Edit and convert PDFs , PDF forms

Views

288

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
Community Expert ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

LATEST

When you hide the fields set also the property "required" as false.

Votes

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