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

Zero = empty… Is it a new bug ?

Community Expert ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Hi experts

 

I think I'm dealing with a new bug in Acrobat: JavaScript no longer knows the difference between nothing and zero.

 

Look at the attached file, there are three buttons, the top one tests if the value is equal to the default value, the middle one tests if the value is nothing and the bottom one tests if the value is zero.
In all cases the answer is the same, whether the fields contain zero or nothing.

 

Have I done something wrong or is this really a bug?


The scripts are in the buttons, this is the first one :

nCompteur = 0;
for (var i=0; i<this.numFields; i++) {
	var oFld = this.getField(this.getNthFieldName(i));
	if (oFld.type != "button" && oFld.required == true && oFld.value == oFld.defaultValue) {
		oFld.strokeColor = color.red;
		nCompteur = nCompteur + 1;
	}
}

console.println("nCompteur = " +nCompteur);

if (nCompteur != 0) {app.alert({cMsg: "At least one field has not been filled in.\nFields that are not filled in are marked in red.", cTitle: "TITLE", nIcon: 1});}
else {app.alert({cMsg: "All fields are filled in", cTitle: "TITLE", nIcon: 1});}

 

Thank you

 

 

TOPICS
Crash or freeze , JavaScript , PDF , PDF forms

Views

237

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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

You can use strict equality to check for empty: oFld.value === ""

View solution in original post

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

You can use strict equality to check for empty: oFld.value === ""

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

LATEST

Thank you Nesa, you're the best!
But why didn't I think of this before? It will remain one of the great mysteries of my life. 😉

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