Copy link to clipboard
Copied
I have a button on my form that checks thats all required fields have been completed before continuing.
One of the required fields is a monetary field. If it's blank, the error message appears as it should, but if 0,00 is typed in, the error message is still appearing saying the field needs to be completed.
This is the code on the button, but I'm not sure what to actually change so it literally only appears if the fields are blank (it ignores 0,00)
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.userName);
}
}
if (emptyFields.length>0) {
app.alert("ERREUR. Au moins une de ces informations suivantes est manquante.\nVous devez compléter l’ensemble de ces informations afin de pouvoir soumettre votre dossier\n\n" + emptyFields.join("\n"));
}
else
this.getField("HIDE.LockDoc").display = display.visible;
{ // All is ok, submit the data
console.println("Votre bon de commande est complet, vous pouvez le soumettre");
}
That's an old version of this code I wrote. Change this line in it:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off"))
To:
if (f.valueAsString==f.defaultValue)
Copy link to clipboard
Copied
That's an old version of this code I wrote. Change this line in it:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off"))
To:
if (f.valueAsString==f.defaultValue)
Copy link to clipboard
Copied
Thank you as always @try67 🙂