Copy link to clipboard
Copied
Hi guys before continuing i must say that I'm very new to Adobe javascript and his community,this is my first question.
I am making a form with acrobat pdf at the last part of the module I put a "save" button linked with an action when pressed the mouse,before doing its task, It's check also if all fields are full or not.
There are some specific text fields that are not required..
So my question is How can i put them into an array list and then delete them? for example with splice(); method?
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if(f.type=="text" && f.value=="") { emptyFields.push(f.name);
}
}
if (emptyFields.length>0) { app.alert("Errore! è necessario compilare i seguenti campi obbligatori:\n" + emptyFields.join("\n"),0);
}
else{ app.alert("Tutti i campi sono stati compilati con successo!",3);
//here then I can save the document form
}
This is the first part of the code
Copy link to clipboard
Copied
If you marked the fields as required then change this part of the code (which I believe I wrote, by the way):
if (f.type=="text" && f.value=="")
To:
if (f.required && f.valueAsString==f.defaultValue)
That will also cause it to work with other field types, not just text fields.
Copy link to clipboard
Copied
If you marked the fields as required then change this part of the code (which I believe I wrote, by the way):
if (f.type=="text" && f.value=="")
To:
if (f.required && f.valueAsString==f.defaultValue)
That will also cause it to work with other field types, not just text fields.

