Show TOC

Procedure documentationDefining Validation Rules Locate this document in the navigation structure

 

You can define a set of validation rules to check the validity of the values of a specific control, and to respond in case of an invalid value. In the Validation Rules dialog box, you define the condition that the control must fulfill, and also the error message that is displayed if validation fails. If the runtime user enters a value that is defined as invalid for the control, the error message you define for the validation condition and value is displayed. For example, you can specify that a control should not be blank, and if it is blank, an error message should be displayed asking the user to specify a value.

In addition to the validation rules that you can define for a specific control, you can also define which controls to validate when a specific action is triggered. If validation fails for a control, the action defined for that control is not performed. You do this in the Validation tab of the Define Action dialog box. We recommend that you leave the default settings in this tab, unless you need to change the validation behavior for a specific control. For example, you may want to remove validation for a Cancel button.

Controls are validated at runtime when the control receives focus. If a control is bound to a data service, it is validated when the data is returned from the data service. If a control fails validation, it may affect its appearance at runtime, and also affect any actions defined for the control. The actual effect of validation failure is defined by a combination of the option selected in the Behavior field of the Configure task panel, and the Validation Behavior option selected in the Validation tab of the Define Action dialog box. For more information about these options, see Configure <Element> Task Panel and Define Action Dialog Box in the Visual Composer Reference Guide.

Prerequisites

On the Layout board, you have selected a control with a field that is bound to it.

Procedure

  1. In the Validation area of the Configure task panel, select the Required checkbox to specify that the control is mandatory and must have a value defined for it at runtime. You can also click the fx icon to open the Dynamic Expression Editor dialog box and define a condition that specifies when the control is mandatory. A control marked as Required shows a visual indication at runtime that it is mandatory.

  2. In the Rules field, click the Browse button to open the Validation Rules dialog box. Define the Condition, Value, and Error Message for each validation rule that you create, and arrange the rules in the order that you want them to be performed. For more information, see Validation Rules Dialog Box in the Visual Composer Reference Guide.

  3. From the Behavior dropdown list in the Configure task panel, select the way in which the control should report validation failures:

    • Normal: If the control validation fails, indicate this visually at runtime in a nonintrusive manner. For example, the control may be marked with a red border, or a tooltip may be displayed.

    • Severe: If the control validation fails, indicate this at runtime in a more intrusive manner. For example, an error message may be displayed in a modal dialog box, or the runtime user may be prevented from moving the focus to another control until the value is changed and the validation is successful.

    Note Note

    The actual behavior of the control at runtime is defined by the runtime environment. The previous descriptions are only examples of possible runtime environment implementations.

    End of the note.

Result

At runtime, the control is validated according to the settings you defined. If the validation fails, the failure is indicated according to the selections that you made. In addition, any actions defined for the control may not be performed.