Skip to main content
Participating Frequently
October 25, 2016
Question

Validating required fields in Acrobat X

  • October 25, 2016
  • 2 replies
  • 1477 views

I created a form in Acrobat X with dropdowns, radio buttons and text fields that are "required" to be completed before the form is sent to another department. I would like a javascript written to tie to Print and Save As buttons I have created that would check these fields before the action is completed. I have checked this forum and other forums and found pieces but I can't get them to work together.

Dropdowns - 'Request in Person' or 'Request by Other' (a selection must be made in one of these fields)

Dropdown - Wire Fees (a selection must be made in this fields)

Radio Buttons - Method of Payment, Funds Available, Account Analysis (a selection must be made in all of these fields)

Text Fields - Beneficiary Name, Beneficiary Account Number, Beneficiary Street Address, Beneficiary City, State, Zip Code

If possible, could the javascript also include a warning message that those fields need to be completed?

Any and all help would be greatly appreciated on this!!

This topic has been closed for replies.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
October 25, 2016

The "required" property that you can assign to fields only works for one specific case: It works for text fields (and not dropdown, checkboxes or radio buttons), and only when you use a "forms submissions". This means that saving or printing will never look at the required property.

What you need to do is to implement your own validation routine that looks at all fields that have the "required" property set (or, you can make this independent from the required property and your validation routine just looks at all fields). When a required field is missing the correct information, you would display a dialog box that instructs the user to provide the missing information. You cannot however interrupt the print or save function - the file will still be printed or saved. What you can do is mark the file as "incomplete" by e.g. having a large form field on top of all other fields that tells the user that the form is not complete. This way, there is no question about a printout - you know if the form was completed, or not.

To hook your own validation function into the print (and/or save) function, you would use a document action script.

Participating Frequently
October 26, 2016

Would you be able to help me with writing the script for the document? I have learned on the fly the easy javascript but this is throwing me for a loop.

Also, would you know a good book for me to use to learn Java? I have looked but haven't found anything.

Thanks in advance for any and all help on this.

Karl Heinz  Kremer
Community Expert
Community Expert
October 26, 2016

There area many books out there to learn JavaScript (it's not "Java" - that's a completely different programming language), but almost all of them are written for browser based JavaScript. When you look at any JavaScript implementation, there are two parts: The core JavaScript language, which is the same across the board, and then application specific extensions, which are all - as the name implies - very specific to each application. This means you cannot use these browser specific extensions in Acrobat and vice versa. This means that it's hard to figure out (as somebody without any experience in JavaScript) where this dividing line is. I am only aware of one book that is specifically for Acrobat: Beginning JavaScript for Adobe Acrobat

Do you know how to create document acting like "Document Will Save" or "Document Will Print"?


Do you know how to loop over all fields in a document?

Participating Frequently
October 25, 2016

The fields referenced above are marked as required under properties.