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

Prevent printing before filling out required fields

Community Beginner ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Hello,
for a form i added a print button, on it is a javascript. Only when I click on the button I get the error message that several required fields have to be filled in, but the printing process starts anyway.
What I have wrong with the code?

 

 

 s1.png

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=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

}

}

if (emptyFields.length>0) {

app.alert("Bitte füllen Sie noch folgende/s Pflichtfeld/er aus, bevor Sie das Formular drucken können:\n" + emptyFields.join("\n"));

}

TOPICS
PDF forms

Views

292

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

correct answers 1 Correct answer

Community Expert , Nov 13, 2020 Nov 13, 2020

You have to do it all in your code. Remove the separate print command and add this to the end of your code:

 

else this.print();

Votes

Translate

Translate
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

LATEST

You have to do it all in your code. Remove the separate print command and add this to the end of your code:

 

else this.print();

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