These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Validating required fields before saving the form

Jesus
Registered: Mar 27 2007
Posts: 54

I have a form developped in designer with several required fields.
 
I need to make shure that all required field are entered before saving the filled form. I notice that the button provided by designder to send an email, it validated that all the fields are entered and if any one is empty, it is marked in red. I noticed that there are not javascripts in that button.
 
I need that functionality in the save button that I included in the form.
 
How can I do that? validate all required fields before saving the form.

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately validation is not included in the save functionality. It's more of a submit thing. But you can force all the validations to executed by placing this script in the "prePrint" event.

form1.execValidate();

Where "form1" is the top subform. This does not stop the document from printing. It just displays the validation message if there is an error. So what you need to do is create a custom print button with your own JavaScript on it. The "execValidate()" function returns true or false depending on the result of the validation test.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

ddcoffee
Registered: Jul 25 2007
Posts: 14
Thom, are you saying that a "SaveAs" button absolutely cannot validate required fields? That your idea of "forcing validations" is only possible with the use of the "prePrint" event of a Print button?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
As it happens, there is a pre-save event as well and the same discussion applies to it.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

ddcoffee
Registered: Jul 25 2007
Posts: 14
Thom -getting close here. I applied the preSave event to the button..no errors, but still won't validate. This is a regular button that already contains an onclick event
app.execMenuItem("SaveAs");
I certainly appreciate your help.
Trainwreck
Registered: Jul 18 2008
Posts: 1
How does one 'capture' a preSave event in standard .PDF forms, not Lifecycle?

Per chance any sample code?

Will the preSave event fire on a Ctrl-S from the user? And if so, what is nessary to re-route them back into the form to fix validation issues (this.resetForum();)?

Thanks for any help/guidance given.