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

Check Required Fields, setFocus (if req) then Print Doc

New Here ,
May 15, 2017 May 15, 2017

I've got follow Javascript code:

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

{

var fieldName = this.getNthFieldName(i);

if ((

this.getField(fieldName).type!="button" && this.getField(fieldName).required==true) &&

(this.getField(fieldName).value=="" || this.getField(fieldName).value=="Off"))

{

app.alert("You must fill in " +fieldName+ " before you can submit the form.");

this.getField(fieldName).setFocus();

break;

}

}

If everthings fine the PDF should print the complete form. How can I insert the this.print string into this script.

698
Translate
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 , May 15, 2017 May 15, 2017

Use something like this:

var print_it = true;

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

{

var fieldName = this.getNthFieldName(i);

if ((

this.getField(fieldName).type!="button" && this.getField(fieldName).required==true) &&

(this.getField(fieldName).value=="" || this.getField(fieldName).value=="Off"))

{

app.alert("You must fill in " +fieldName+ " before you can submit the form.");

this.getField(fieldName).setFocus();

print_it = false;

break;

}

}

if (print_it) this.print();

Translate
Community Expert ,
May 15, 2017 May 15, 2017
LATEST

Use something like this:

var print_it = true;

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

{

var fieldName = this.getNthFieldName(i);

if ((

this.getField(fieldName).type!="button" && this.getField(fieldName).required==true) &&

(this.getField(fieldName).value=="" || this.getField(fieldName).value=="Off"))

{

app.alert("You must fill in " +fieldName+ " before you can submit the form.");

this.getField(fieldName).setFocus();

print_it = false;

break;

}

}

if (print_it) this.print();

Translate
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