Javascript - Fillable form in Acrobat
Good morning,
I am trying to set up a JS that allows a button to look for any missing required fields. Text fields and radio buttons are the types of fields that are required throughout this form. I need it to prompt all missing required fields, then once all are complete, prompt that the form is complete and ready to be printed, then followed with the print screen. At this point, I cannot figure out how to get it to point out the radio buttons or prompt when complete. It does pop up the message for the text fields and does pop up the print screen once "complete", however, whether the radio button options are selected or not, it shows all radio buttons in the error as if they were not completed. There is one gender radio button selection and the rest are "yes"/"no" type of options where they have to go through and click either yes or no on all listed. The default is set to where neither is selected.
This is what I have so far. Can you please let me know how this can be changed in order to do what I need it to do? Thanks in advance.
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=="radio button" && f.value==""))
f.strokeColor = color.red; //Highlights the required fields in red
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
}
else app.execMenuItem("Print");
