The script object is an object you can use to store JavaScript functions and values separately from any particular form object. Typically, you use the script object to create custom functions and methods that you want to use as part of JavaScript scripts in many locations on your form. This technique reduces the overall amount of scripting required to perform repetitive actions.
The script object only supports script written in JavaScript; however, there are no restrictions on the location where the scripts are executed, provided that the scripting language for the event that invokes the script object is set to JavaScript.
Both Acrobat and Forms process scripting from a script object in the same manner, but both are also distinct.
Only scripts set to run on the client can make use of script objects set to run on the client, and vice versa.
There are two parts to creating a script object. The first part involves adding the object to the form design, and the second part is writing the script you want to store in the script object.
View full size graphic
A. Form level object B. Subform level object C. Subform level script object D. Form level script object
After you have a script object on your form, you can add scripts using the Script Editor.
View full size graphic
For example, create a script object called feedback that contains the following function:
function emptyCheck(oField) < if ((oField.rawValue == null) || (oField.rawValue == "")) < xfa.host.messageBox("You must input a value for this field.", "Error Message", 3); >>
After you add scripts to a script object, you can reference the script object from any event that supports JavaScript scripts.
Similar to referencing other objects on a form, you must provide a valid syntax when referencing the script object that includes where it exists within the form hierarchy. For more information about referencing objects in scripting, see Referencing object properties and values.
For example, using the script object example from To add script to a script object, place the following JavaScript script on the exit event for a text field. Test the form using the Preview PDF tab.
Twitter™ and Facebook posts are not covered under the terms of Creative Commons.