Hi everyone,
I am new to using Javascripts in Acrobat Professional. I created an application form (3 pages) and applied "Print form" & "Submit form" buttons at the end of the document.
There are many fields in the form that are mandatory for the applicant to fill in.
I am looking for a way to validate and maker sure all the fields are filled before submitting the form via email.
Any help is appreciated, thanks in advance for your time.
Cal.
There is actually a field property "required". Unfortunately, it is of rather limited use, because it is only the Submit action which honors it. You may use it in order to determine whch field should be evaluated. You may also use any other field property (in many of the projects I provided the engine, we evaluate the field's border color.
In pseudo-code the procedure would look somewhat like this:
var cnt = 0 // that's the counter
for (var fi = 0 ; fi < this.numFields ; fi++) {
var fifi = this.getNthFieldName(fi) ;
if (fifi.includeproperty == includepropertyvalue) {
if (fifi.value == fifi.defaultValue) {
cnt++ ;
}
}
}
if (cnt > 0) {
// send failure message
} else {
// proceed with submit or print
}
And that would be your evaluation routine.
Note that in the case of printing, you would have to create a big "Print Me" button, and instruct the user to only use this button, because there is no known way in JavaScript to stop a print command issued via keyboard shortcut, menu action or toolbutton.
Hope this can help.
Max.