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();
}
}
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.
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.
Copy link to clipboard
Copied
Exactly what I am looking for. If any field is hidden, ignore the field or the "*".
Thanks.
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.
Copy link to clipboard
Copied
Thank you.