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

Script for checkbox#0 checkbox#1 not show in alert

New Here ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

Hello,I have found the following Javascript code (from here Re: Check to see if any field is empty)  and join code && f.page =="0" to check page1, text and check box can show right, but if checkbox is same name ex:checkbox#0 checkbox#1  ,it will not showing into alert, how to identify code ,thank you for help!

var emptyFields = [];

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

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

if (f.type!="button" && f.required && f.page =="0")

{ if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name) ; } }

if (emptyFields.length>0) { app.alert("請輸入下列欄位 \n" + emptyFields.join("\n")); } 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

297

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 , Jan 16, 2022 Jan 16, 2022

The notation "checkbox#0 checkbox#1" is only shown in the Prepare Forms field list panel. They are not real form field names. The #0 and #1 are only there to let you know that they are instances of the same field.  Because they are the same field they share many properties. But since they are different instances they each have some different properties. The collision of these two concepts is the page property. To resovle the inherent conflict it is made into an array of page numbers for the inst

...

Votes

Translate

Translate
Community Expert ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Info: the page property can be an array.

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 ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

i can't unedrstand. if the page property can be an array ,then why not show checkbox#0 checkbox#1

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
Community Expert ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

The notation "checkbox#0 checkbox#1" is only shown in the Prepare Forms field list panel. They are not real form field names. The #0 and #1 are only there to let you know that they are instances of the same field.  Because they are the same field they share many properties. But since they are different instances they each have some different properties. The collision of these two concepts is the page property. To resovle the inherent conflict it is made into an array of page numbers for the instances of the field. 

 

The way to hand this in code is to convert it into an array. then use array code to do the page check.

So replace   f.page == "0"  (which by the way is already incorrect)

with this    ((typeof(f.page)=="number")?[f.page]:f.page).some(a=> a==0)

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 16, 2022 Jan 16, 2022

Copy link to clipboard

Copied

LATEST

it work perfect! thank you !

 

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