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

40

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

Copy link to clipboard

Copied

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

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