With FormMaker, not only is it possible to produce fully-formatted Acrobat forms in InDesign as with FormMagic, it is even possible to attach Acrobat validation, calculation, and formatting scripts to each form field right inside InDesign. You can also add document scripts, and keyboard and mouse action scripts – all in InDesign!
Important update (September 2020): FormMaker has been updated is now much easier to use. The InDesign screenshots below are no longer applicable, therefore. With the new FormMaker you can easily insert validation scripts into your fillable PDF forms in InDesign without writing a line of code!
In this post, I will take you through the steps necessary to add an all-caps validation script to your PDF form, using FormMaker.
The end result will be an Acrobat PDF form in which a text field will be designated as a capital-letters-only field. Whatever the user types in will be converted automatically to all caps.
The first step is to design a simple form in InDesign. Here’s the one I’ll be using:
In this example, I want to make sure that the name the user types into field 1 (“Name of Organization”) will always be in all-capital letters. So, even if they type “Ace Design Agency”, as soon as they focus out of the field in Acrobat, I want that to change to “ACE DESIGN AGENCY”.
The way to do this in Acrobat is to attach a script to the validation event of the form field. Select the field in Acrobat with the black arrow, click on “Properties”, go to the “Validate” tab, and add the necessary script, as in the following screenshot:
The problem with doing this in Acrobat, though, rather than in InDesign directly, is that every time a change is made to the form, that change will have to be made in InDesign, meaning that all the validation scripts will need to be added again to each field after the form is re-exported to Acrobat.
If there are many rounds of revisions and updates, clearly this is a huge waste of time.
It would be great to be able to add such scripts to the form directly in InDesign. That way, it would only be necessary to do it once, no matter how many rounds of corrections there are.
Using FormMaker, this is possible, and it’s is as easy to do in InDesign as in Acrobat. The steps are as follows:
- Open the form in InDesign.
- Select the form field to which you would like to add an Acrobat validation script.
- Open the “Script Label” panel in InDesign (Window > Utilities > Script Label).
- In the Script Label panel, type the first line as follows. This line tells FormMaker that you want to attach a validation script to the field.
- Now type (or paste) the actual validation script as needed.
- Finally, finish off with the following line. This tells FormMaker that the script has ended at this point. (You could append another script here if needed.)
- The Script Label panel should now look like this InDesign screenshot:
Repeat steps 2–6 for each field to which you would like to add a validation script.
Once that is done and the form is complete in InDesign, run FormMaker in InDesign, export to interactive PDF as usual, and run FormMaker again in Acrobat.
Now, apart from all the visual formatting that is restored, FormMaker also restores all validation scripts to each field appropriately.
Here’s the actual PDF to test the result out on. To see the validation script in action, type something with lowercase letters into field 1 (e.g. “Ace Design Agency”). Tab out of the field, or click into a different field, and notice how the text of field 1 has been changed to all-capital letters.
Don’t forget: Everything in this form was created directly in InDesign with FormMaker, including the font, color, alignment, and even the comb fields!
Of course, converting user entries into all-capitals is only one of an infinite number of things that can be done. Other common uses might be to check the validity of an email address, or to limit entry to a range of numbers, to check for valid dates or a range of dates, and so on.
And FormMaker is not limited to validation scripts. Check out the online Help page for more info.
If you need help writing the Acrobat scripts you require, we’d be happy to help with that.
Questions? Comments? Get in touch!