Copy link to clipboard
Copied
Hi everyone, I am creating PDF forms with text fields to be filled in and I wish the document could not be saved if these fields are not filled in. I have set the fields as mandatory but there seems to be no difference between mandatory and non-mandatory fields and the document can be easily filled in without rules. How can I force this thing? Has anyone already had similar experiences or needs?
Copy link to clipboard
Copied
You can use this script:
var nCompteur = 0;
for (var i=0; i<this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type != "button" && oFld.type != "signature" && oFld.required == true && oFld.value == oFld.defaultValue) {
nCompteur = nCompteur + 1;}
}
if (nCompteur != 0) {app.alert(nCompteur + " required fields are not filled in." );}
Copy link to clipboard
Copied
"Required" forms applies only to submit actions. It doesn't block saving, which is very important as people often need to save half-completed forms to come back later.
In general, submitting to an https server (NOT email) and not saving is the way forward. Saving has all sorts of other issues, like overwriting work by accident.
Copy link to clipboard
Copied
It would be penalizing, a user may have many good reasons to want to save a form being filled out to finish it later.
It is more user-friendly to simply display an alert when saving (using a script in : Document Actions : Document Will Save).
Copy link to clipboard
Copied
Is it possible with Adobe Acrobat to insert this notice to warn the user that not all the forms have been filled in and that he can continue and save or go back and continue?
Copy link to clipboard
Copied
You can use this script:
var nCompteur = 0;
for (var i=0; i<this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type != "button" && oFld.type != "signature" && oFld.required == true && oFld.value == oFld.defaultValue) {
nCompteur = nCompteur + 1;}
}
if (nCompteur != 0) {app.alert(nCompteur + " required fields are not filled in." );}