Skip to main content

Developing an Application

 

OutSystems

Validate Form Inputs

When a form is submitted, OutSystems performs built-in validations for mandatory fields and valid data types. However, you can also add your own custom form validations.

In mobile

Use the client action that is executed when the form is submitted to perform client-side validations. Add all validations to the action flow before the existing If element that tests the value of Form.Valid.

For each validation:

  1. Add the logic to validate the input value.

  2. If the validation fails, assign the input’s runtime properties as follows:

    • Input.Valid = False
    • Input.ValidationMessage = "<your error message>"

If any of the built-in validations fail or you assign False to the Valid runtime property of any field of the form, the Valid property of the form is automatically assigned to False. In this case, the validation messages are displayed next to all the corresponding inputs that are not valid. If you want to validate inputs on the server side, send them as inputs to a server action where you implement your server-side validation logic.

In web

Use the server action that is executed when the form is submitted to implement the form validations. Add all validations at beginning of the action flow:

  1. For each validation:
    1. Add the logic to validate the input value.
    2. If the validation fails, assign the input’s runtime properties as follows:
    3. Input.Valid = False
    4. Input.ValidationMessage = "<your error message>"
  2. Check the value of Form.Valid after all input validations because if any of the inputs is not valid, the form is also not valid:
    1. Add an If element with the following condition: Form.Valid
    2. If True, continue the action flow.
    3. If False , end the action flow. The form displays validation messages next to all inputs that are not valid.

If any of the built-in validations fail or you assign False to the Valid runtime property of any field of the form, the Valid property of the form is automatically assigned to False. In this case, the validation messages are displayed next to all the corresponding inputs that are not valid.