Skip to main content

Add Required Fields

Last updated 16/12/2021

How to Add Required Fields to a Form

This documentation will explain how to add fields to a form that are required to have a value entered.

By writing a condition in JavaScript® you can choose to make a field mandatory to have a value according to your requirements. The condition can be as simple as:

  • true to make the field required, or
  • false to make the field not required

Default

  • true for the first field
  • false for all other fields

Example

You can write a condition using Five's API and specify that if the Field ID on the current form is empty or NULL make the field with the condition true.

(form.FieldID === '' || form.FieldID === NULL)

On an Employee form you may have the fields Email and Phone. By writing the conditon (form.Email === '' || form.FieldID === NULL) in the Phone field, the result will be that if the Email field is empty or NULL make the Phone field required.

Steps

  1. Select Forms in the menu.
  2. Select the required form record in the list.
  3. Click the Pages tab.
Select the Form Record
Figure 1 - Select the form record

  1. Select the required page record.
Select the Page Record
Figure 2 - Select the page record

  1. Click the Fields tab.
Fields Tab
Figure 3 - Fields tab

  1. Select the required field record.
Select the Field Record
Figure 4 - Select the field record

  1. Either click the Edit button in the form app bar or click in the Required If field.
Edit the form
Figure 5 - Edit the form

  1. Type your condition, (form.Email === '' || form.FieldID === NULL), in the Required If field.
  2. Click the Save button in the form app bar.
Type Condition and Save the Form
Figure 6 - Type the condition and save the form

  1. Click both Save buttons in the stacked form app bars above the list.
Save the Form
Figure 7 - Save the form

info

A condition can be added to the Required If field on the creation of the form.

How This Will Look in Your End-User Application

A required form field will be marked with an asterisk in your end-user application to signify the field is required. A user trying to save a form without inputting data in a required field will be delivered a notification that the field requires a value before it can be saved.

In the end-user application the Phone field will be marked with an asterisk.

Phone Field is Required
Figure 8 - Phone field is required

If a value is entered in the Email field, the Phone field will no longer be required.

Phone Field is No Longer Required
Figure 9 - Phone field is no longer required