Skip to main content
Kinetic Community

Make one Field Conditional on the Answer of another Field

Overview

An advantage to software forms is that developers can add dynamic behavior.  This article covers how to make a form field required based on the answer of another field.

This article assumes that the reader is already familiar with the Kinetic Request console and specifically the Form Builder.

Usage

This can be very useful tool for form developers. Based on a user's input you may want to display fields to get more information. Is the information required for the successful completion of the request? If so add validation to the field.

This leaves a form developer in a little bind, because not all users may need to fill out this required field. It is only required based on the answer of another question.

Here comes Kinetic Data to save the day. The form developer has tools to make a field required based on the condition of another field.

Example

A simple example of how this could be useful to a form developer. A request asks the question "Will you need a new laptop?". Based on the answer to that question the user must provide a department charge number.

This example will only have those two questions. In a production setting there would be many other questions for the user to fill out.

  1. Add a Radio Button field with the values Yes and No.

    Form Builder
     
  2. Add a Text field to gather the department charge number.
  3. With the text field selected click the Validation dropdown and select the Conditional radio option the the right or Required.
  4. The Condition field is required.  Add an expression that will evaluate to true or false. (If true the field will become required)
  5. A Message to display to the user in optional.  (If omitted a default message is provided) 

If the user selects "No" to the question then the Department Charge Number field is not required.

Form View

If the user selects "Yes" then a red asterisk becomes visible to the right of the Department Change Number field.

Form View 2

If a user attempts to submit the form without the required field being valid then a alert message is displayed to them.

Form View 3