Building JavaScripts

Oracle Portal allows you to create JavaScripts that perform validation on entry fields in forms and customization forms. Field-level validation is performed when the end user causes the OnBlur condition to occur after entering a value in an entry field, for example, when tabbing to another entry field. Form-level validation occurs after the user enters a value in an entry field and submits all values on the page, for example, when clicking an OK button.

Follow these guidelines when writing a field- or form-validation JavaScript. All validation routines should be written as functions, and return either TRUE or FALSE values.

The following JavaScript validates that the user enters a numeric value into an entry field:

1) Identifies the name of the function and the entry field being validated.

2) Checks whether the absolute value of the entry field is a number. IsNaN ("Is Not a Number") is a JavaScript function.

3) If the value in the entry field is not a number, the user is alerted with the message, "Value must be a number."

4) The routine brings focus to the entry field.

Oracle Portal ships a default set of JavaScript routines

You must have Create or higher shared database portlet access privileges to create a JavaScript.

You must have Manage shared database portlet access privileges to edit a JavaScript.

To build a JavaScript:

  1. In the Oracle Portal Navigator, navigate to the list of JavaScripts.

  2. Click Create>, then JavaScripts.

  3. In the JavaScript Name field, type a descriptive name for the JavaScript; for example, NotNull for a JavaScript that ensures there are no null values in an entry field.

  4. In the Language field, type the language in which the JavaScript will be written; for example, JavaScript1.1 or JavaScript1.2.

  5. Click Next>.

  6. Type or copy your JavaScript into the field provided.

  7. Click Finish.

  8. (optional) If you have Manage shared database portlet access privileges, you can edit the JavaScript you just created. To do so,click the Edit link in the Actions column in the Oracle Portal Navigator.

Notes

Related topics

Default Javascripts
Testing Javascripts
Editing, deleting, and exporting shared database portlets