How can I check an input is valid?

Is there anyway to make sure what the user types into a data field fits some criteria? Eg Regular expressions or something similar?

Thanks!

Hi BillyTheKid,

There are a couple of ways you can validate data that a user inputs in a field in your application.

You can make your own custom display type in Five with a regular expression and attach this to a form field. The video below demonstrates how to do this and how it works in an application.

Steps

  1. Select Display Types in the menu.

  2. Click the Add Item button.

  3. Type a name in the Name field.

  4. Select a display type in the Display Type field.

  5. Click the Regular Expression switch.

  6. Type your RegEx in the Mask Field.

  7. Optional - Type a message in the Error Message field.

  8. Save your display type.

  9. Navigate to the required form field record.

  10. Select the display type you just created in the Display Type field’s lookup.

  11. Save your form.

You can also use the On Validate Event to validate data entered in a form field. The video below demonstrates how to do this and how it works in an application.

Steps

  1. Select Functions in the menu.

  2. Type an ID in the Function ID field.

  3. Select a language in the Language field.

  4. Click in the Code field to open Five’s Code Editor.

  5. Type your code.

  6. Click the Save button in the Code Editor.

  7. Save your function.

  8. Navigate to the required form field record.

  9. Click the Events tab.

  10. Select the function in the On Validate field’s lookup.

  11. Save your form.

1 Like