Skip to main content
Participant
November 29, 2019
Question

action button (email) does not work properly

  • November 29, 2019
  • 1 reply
  • 348 views

Hi, In my form I used an action button to email the form once the required field are filled. If not a message has to appear and the missing field are highligted in red. I used a Script I found in this forum

 

var emptyFields = [];

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null || f.type=="button") continue;

    if (f.required && f.valueAsString==f.defaultValue) {

        f.strokeColor = color.red;  //Highlights the required fields with red outline

        emptyFields.push(f.name);

    } else f.strokeColor = color.gray; //Highlights the filled in fields with gray outline

}

if (emptyFields.length>0) {

    app.alert("WAIT! You must fill in all of the required fields before printing this form");

} else this.print();

At first it seems to work but when I click the message the email is made anyway. How can this be solved so that an email is only made when all the required fields are filled?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 29, 2019

Remove the "Submit a Form" command and change the last line of the code to:

 

} else this.mailDoc({cTo: "me@server.com"});

Floris11Author
Participant
December 2, 2019

thanks