1. Home
  2. Tutorials
  3. Creating your App UX
  4. Validate User Input

Validate User Input

invalid entry alert
If your app captures user input and you want to validate it before sending it to an API or carrying out further processing on it, you can do so using conditional Actions. You can carry out validation when an Event occurs in the app, such as the user submitting their input by tapping a button, or interacting with the Element you want to validate.

To validate when the user submits by tapping a button:

  • Select the button Element and open Properties > Events. Open the Tapped Event.

To validate when the user interacts with the Element you’re checking:

  • Select the Element and open Properties > Events. Select the relevant Event, such as Value Changed or Returned for a Text Field.

With your Element Events open for managing:

  • Add an Action, selecting If… Else.
    • In the first input, use the Elements container to select the property representing the Element input value you want to check, for example the Text property for a text input Element. text is empty If you want to check for an empty value, select Text > Is Empty.
    • In the center input select an operator, for example == to check for equality with your next input.
    • In the third input, select or enter a value representing your required input, for example a Static Input Boolean value of True if you’re using Is Empty. test input true
  • In the nested True Event, add an Action to respond to the test returning a true result. For example, if you checked that text input was empty, you could output an error message prompting the user to complete their input – use either a Show Alert Action to display the message, or a Set Value Action to show it in Elements in the page. error message input
  • In the nested False Event, add an Action to respond to the test returning a false result. For example, if false means the input is valid, carry out any processing you need for successful input, such as running an API request that uses the input. select valid request

If you’re using an API that returns error status codes, you can respond to them in your app. You can also validate the data returned from a request using API Events. You can display a dynamically updating indicator of how many characters a user can enter into a text field using the Calculate Math Expression Action.

invalid entry snackbar
If your app captures user input and you want to validate it before sending it to an API or carrying out further processing on it, you can do so using conditional Actions. You can carry out validation when an Event occurs in the app, such as the user submitting their input by tapping a button, or interacting with the Element you want to validate.

To validate when the user submits by tapping a button:

  • Select the button Element and open Properties > Events. Open the Tapped Event.

To validate when the user interacts with the Element you’re checking:

  • Select the Element and open Properties > Events. Select the relevant Event, such as Text Changed for a Text Field.

With your Element Events open for managing:

  • Add an Action, selecting If… Else.
    • In the first input, use the Elements container to select the property representing the Element input value you want to check, for example the Text property for a text input Element. text field validate
    • In the center input select an operator, for example == to check for equality with your next input.
    • In the third input, select or enter a value representing your required input, for example a Static Input String with an empty value to check if the user has entered nothing. text field empty
  • In the nested True Event, add an Action to respond to the test returning a true result. For example, if you checked that text input was empty, you could output an error message prompting the user to complete their input – use either a Show Snackbar Action to display the message, or a Set Value Action to show it in Elements in the page. error message input
  • In the nested False Event, add an Action to respond to the test returning a false result. For example, if false means the input is valid, carry out any processing you need for successful input, such as running an API request that uses the input. select valid request

If you’re using an API that returns error status codes, you can respond to them in your app. You can also validate the data returned from a request using API Events. You can display a dynamically updating indicator of how many characters a user can enter into a text field using the Calculate Math Expression Action.

Was this article helpful to you? Yes No

How can we help?