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

action button (email) does not work properly

New Here ,
Nov 29, 2019 Nov 29, 2019

Copy link to clipboard

Copied

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?Capturepdf.JPG

TOPICS
Acrobat SDK and JavaScript

Views

200

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
Community Expert ,
Nov 29, 2019 Nov 29, 2019

Copy link to clipboard

Copied

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

 

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

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
New Here ,
Dec 02, 2019 Dec 02, 2019

Copy link to clipboard

Copied

LATEST

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