Previous Topic: Attributes for Text Fields and Text Areas OnlyNext Topic: How to Perform Automated Tasks for Fields


JavaScript Attributes

You can use JavaScript attributes to invoke JavaScript functions while the user is completing the form in a request. Examples include onChange, onKeyUp, onBlur, and so forth. JavaScript functions include predefined functions for validating user input into fields and any custom functions that you have written. All JavaScript attributes are named with the prefix on, such as onClick.

You can use the following JavaScript attributes in elements on forms. Not all attributes apply to all elements, however. Click an element to see which attributes apply to it.

Important! JavaScript attributes must have JavaScript functions but not JavaScript expressions as values. Conversely, HTML attributes can have JavaScript expressions but not JavaScript functions as values. Thus, JavaScript expressions apply to HTML attributes only, and JavaScript functions apply to JavaScript attributes only.

JavaScript functions specified in JavaScript attributes are validated when the user performs the action specified by the attribute, such as click or double-click. If the field does not validate, it is highlighted in red and an error message appears explaining why the validation failed.

Note: Verify that the error messages (if any) returned by each JavaScript function are localized for the users of the form.

onFocus

Specifies the JavaScript function to run when the element comes into focus.

onBlur

Specifies the JavaScript function to run when the element loses the focus.

onChange

Specifies the JavaScript function to run when the element value is changed.

onClick

Specifies the JavaScript function to run when the component is clicked with the left mouse button.

onLoad

Applies to dual lists and select boxes only.

Specifies the JavaScript function to run when the data associated with the select is loaded. This attribute is ignored if the dual list or select box specifies static options.

An alert appears if an onLoad function fails to run correctly, for example, if the function cannot be found. If you receive an alert, verify that function is correctly defined and referenced, and that the function runs without errors.

As a best practice, use the Script dialog on each form to create and maintain the custom JavaScript functions for the form.

onMouseDown

Specifies the JavaScript function to run when a mouse button is pressed.

onMouseUp

Specifies the JavaScript function to run when a mouse button is released.

onMouseOver

Specifies the JavaScript function to run when the component is moused over.

onMouseMove

Specifies the JavaScript function to run when the mouse passes over the component.

onMouseOut

Specifies the JavaScript function to run when the mouse was moved away from the component.

onKeyPress

Specifies the JavaScript function to run when a key is pressed and released.

onKeyDown

Specifies the JavaScript function to run when a key is pressed.

onKeyUp

Specifies the JavaScript function to run when a key is released.

onValidate

Specifies the JavaScript function to run when the field is validated. The field is validated whenever the user navigates away from a field or when the user submits the form.

If you specify a custom JavaScript function for the onValidate attribute, code that function to do the following:

onLookup

Applies to lookup fields only. When the user clicks the magnifying glass for the lookup field, the JavaScript function specified by this attribute runs. You can use a lookup field to populate fields based on user input to a report data object.