Using the Validation Rules Editor

This document covers the following topics:


About the Validation Rules Editor

The validation rules editor can be used to define that the value that is entered in a field must meet certain conditions. You can test your validation rule in the preview area. If an invalid value is entered, a corresponding message appears. Example:

Message

Important:
The validation is done on the client side.

Opening the Validation Rules Editor

When you open the validation rules editor, you can add, modify and remove validation rules.

Start of instruction setTo open the validation rules editor

  1. In the layout area or preview area, select the field control that you want to validate.

  2. From the Ajax Developer menu, choose Insert/Edit Validation Rules.

    A dialog appears. If validation rules have already been defined, the messages that have been defined for these rules are shown in the text box. Example:

    Validation rules editor

    The following command buttons are provided:

    Command Button Description
    Add Adds a new validation rule. See below.
    Modify Modifies the selected validation rule.
    Remove Removes the selected validation rule.

Adding a New Validation Rule

The prerequisite for adding a validation rule for a field is that an adapter class or Natural adapter with the corresponding code exists for the field. Otherwise, the field does not appear in the validation rules editor.

You can add more than one validation rule.

Start of instruction setTo add a new validation rule

  1. To add a validation rule, choose the Add button.

    Additional information is now shown at the bottom of the dialog.

    Validation rules editor

  2. From the first drop-down list box, select the name of the field for which you want to add a condition.

  3. From the second drop-down list box, select the condition (for example, "less than").

  4. In the third box, enter the value for the condition (for example, "100").

  5. Optional. From the fourth drop-down list box, select the operator And or Or if you want to define an additional condition. In this case, you have to choose the Add button which is shown in the lower part of the dialog and specify the required values in the resulting line (as described above).

  6. In the Message text box, enter the message that is to appear in a dialog box when an invalid value is entered (for example: "The value in the field must not be less than 100!").

    Or:
    If you are working with several languages, enter a text ID in the Text ID text box. See also Multi Language Management in the Natural for Ajax documentation.

  7. From the Events drop-down list box, select one of the following values. This defines the behavior in the case of an error.

    Event Description
    onchange Your message will appear when the user leaves the input field.
    onsubmit Your message will appear when the information is about to be transferred to the server (for example, by choosing a Save button).

    The lower part of the dialog may now look as follows:

    Validation rules editor

  8. Optional. If you want to delete a condition, select the corresponding row and choose the Delete button.

  9. To confirm the new validation rule, choose the OK button in the lower part of the window.

    The dialog is not closed and you can add further validation rules.

  10. To confirm all validation rules and to close the window, choose the OK button in the upper part of the window.

Displaying an Overview of All Defined Validation Rules

You can display a list of all validation rules which are defined in the current layout.

Start of instruction setTo display an overview

  • From the Ajax Developer menu, choose Validation Rules Overview.

    A dialog appears. When validation rules have been defined in the current layout, they are listed in this dialog.

    Validation rules overview

    When you click on a validation rule, the validation rules editor appears and you can change the validation rule as described above.