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
Copy link to clipboard
Copied
You can use strict equality to check for empty: oFld.value === ""
Copy link to clipboard
Copied
You can use strict equality to check for empty: oFld.value === ""
Copy link to clipboard
Copied
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. 😉