Set validation rules in the frontend

In addition to simple mandatory field declarations, more complex validation rules can make working with forms and tables in GAPTEQ applications even more targeted and error-neutral.

In this article you will read the following content: 

Set validation rule in Data Form component

Display list of validation errors

You can assign validation rules to each form field in GAPTEQ so that saving is only possible if all the desired conditions are met. If this is not the case, an individual error message is displayed directly in the form field.

Optionally, all error messages of the triggered validations can be displayed as a list. When clicking on an error message, the cursor is placed on the form field to be corrected.

Note! The procedure for setting the validation rules is identical for the two relevant components Data Grid and Data Form. The procedure for the Data Form component is explained in the article.

1. Set validation rule in Data Form component


The following validation requirements are to be implemented as an example: 

Form field 2 “Actions taken in case of defects” (german version in screenshot: "Ergriffene Maßnahmen bei Mängel" must not be empty if form field 1 “Defects detected” (german version in screenshot: "Festgestellte Mängel") has been filled in.

TD_FT_FrontendValidation_Screenshot_1

  • Click on “Validation” in the properties/properties of the form field to open the editor window.

TD_FT_FrontendValidation_Screenshot_2

Note! The programming language of GAPTEQ Custom Expressions is JavaScript. The editor provides all available objects and enables error-free insertion into the script.

  • A return true as the return value indicates that the check is valid.
  • A return false triggers the defined error message and prevents the data record from being saved.

The query in the example triggers an error message if defects have been recorded but no measures have been entered. If no defects are recorded, no entries are required for measures. Error messages are displayed directly on the form field.

TD_FT_FrontendValidation_Screenshot_3

2. Display list of validation errors

If several validations have been defined in a data form, these can optionally be displayed as a list.

  • This functionality is activated with the “Show validation summary” checkbox in the properties of the data form.

TD_FT_FrontendValidation_Screenshot_5

Tip! You can find an example of how to set a validation rule in the Data Form component in the GAPTEQ SAMPLE APP Incoming Goods Control (in the pageFormControl). An example of setting validations in the Data Grid can be found in the GAPTEQ SAMPLE APP Inventory, in the Data Grid column 'Quantity per unit' on the page pageArticle.