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")); }
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
...Copy link to clipboard
Copied
Info: the page property can be an array.
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
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)
Copy link to clipboard
Copied
it work perfect! thank you !