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

Required hidden field

Participant ,
Jun 16, 2018 Jun 16, 2018

Copy link to clipboard

Copied

Hi, I have a field that shows if a certain checkbox is checked. Otherwise it is hidden.

If you check chsckbox 2, the other field stays hidden and is not required.

Does not work, I get the required error either way. Does it matter if doc level script or on the actual button?

function validateFields()

{

//a counter for the number of empty fields

var flg = 0

// count all the form fields

var n = this.numFields

//create an array to contain the names of required fields

//if they are determined to be empty

var fArr = new Array();

//loop through all fields and check for those that are required

// all fields that have a '*' in their tool tip are required

for(var i = 0;i<n;i++){

var fn = this.getNthFieldName(i);

var f = this.getField(fn);

//tool tip is the fields\'s 'userName' property;

var tt = f.userName

//test for the '*';

if(tt.indexOf('*')!=-1 && f.value == f.defaultValue){

//increment the counter of empty fields;

flg++;

//add the fields userName (tool tip) to the list of empty field names;

fArr[fArr.length] = tt;

}

}

//now display a message if there are empty fields

if(flg>0){

app.alert('There are '+flg+' fields that require a value\n\n'+ fArr,3)

}

else{

this.print();

}

}

TOPICS
PDF forms

Views

1.0K

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
1 ACCEPTED SOLUTION
LEGEND ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

You have the field object so just test the hidden property (fieldobject.hidden). The documentation however recommends you use fieldobject.display which is more complicated.

View solution in original post

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
LEGEND ,
Jun 16, 2018 Jun 16, 2018

Copy link to clipboard

Copied

This code seems to show that you aren't using the "required" field property, but using your own test based on the tooltip starting with "*". Which is fine. But what you haven't showed us is what you do towards making the one particular hidden field not required? It will still be in the Fields array and still have whatever tooltip you gave it.

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
Participant ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

Exactly what I am looking for. If  any field is hidden, ignore the field or the "*".

Thanks.

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
LEGEND ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

You have the field object so just test the hidden property (fieldobject.hidden). The documentation however recommends you use fieldobject.display which is more complicated.

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
Participant ,
Jun 17, 2018 Jun 17, 2018

Copy link to clipboard

Copied

LATEST

Thank you.

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