---
title: How to make a field required/not required based on a 'Yes' or 'No' selection
description: "In OFS-Flow, you can create validation to make a field mandatory only when a specific answer, like \"Yes,\" is chosen in a previous field. If \"No\" is selected, the field will remain optional. This is useful for forms where a \"Yes\" answer requires a mandatory comment or corrective action, but a \"No\" answer does not."
---

[Skip to content](https://support.ofsystems.com/how-to-make-a-field-required/not-required-based-on-a-yes-or-no-selection#main-content)

![OFS\_Circle.png\]](https://support.ofsystems.com/hs-fs/hubfs/OFS_Circle.png?height=45&name=OFS_Circle.png)

- [OFS Customer Portal](https://support.ofsystems.com/)
- [Main Website](https://ofsystems.com/)
- [Contact Us](https://www.ofsystems.com/contact-us?)
- [Service Portal](https://ofsystems.atlassian.net/servicedesk/customer/portal/1)

Open main navigation

Close main navigation

- [OFS Customer Portal](https://support.ofsystems.com/)
- [Main Website](https://ofsystems.com/)
- [Contact Us](https://www.ofsystems.com/contact-us?)
- [Service Portal](https://ofsystems.atlassian.net/servicedesk/customer/portal/1)

 Welcome to the OFS Customer Portal

- There are no suggestions because the search field is empty.

1. [OFS Customer Portal](https://support.ofsystems.com/?hsLang=en)
2. [How To Questions](https://support.ofsystems.com/how-to-questions?hsLang=en)
3. [Flow - Validations](https://support.ofsystems.com/how-to-questions?hsLang=en#flow-validations)

# How to make a field required/not required based on a 'Yes' or 'No' selection

## In OFS-Flow, you can create validation to make a field mandatory only when a specific answer, like "Yes," is chosen in a previous field. If "No" is selected, the field will remain optional. This is useful for forms where a "Yes" answer requires a mandatory comment or corrective action, but a "No" answer does not.

#### What you'll build

- A selection field, e.g. **Did you run a job?**, with "Yes" and "No" options.
- A text field, e.g. **Field A**, that becomes mandatory only when "Yes" is selected.

#### **Step 1 — Open the form**

Navigate to your alert and open the **Form** tab.

#### **Step 2 — Open the Field Validation Rules tab**

Select **Field A** and go to the **Field Validation Rules** tab. The rules below are set on **Field A** and are processed in order, from top to bottom.

#### **Step 3 — Add the validation rules in order**

**Rule 1 — mark as Valid if "No" is selected:**

 

```
data["Did you run a job?"]=="no"
```

 This checks the selection field first. If it's "No", **Field A** is marked valid even if it's empty, and no further rules run for this field. Click **Valid** to set the status, colour, and a message.

![Screenshot 2025-11-12 at 3.59.27 pm](https://support.ofsystems.com/hs-fs/hubfs/Screenshot%202025-11-12%20at%203.59.27%20pm.png?width=631&height=193&name=Screenshot%202025-11-12%20at%203.59.27%20pm.png)

**Rule 2 — mark as Valid if "Yes" is selected and the field is filled:**

```
(data["Did you run a job?"]=="yes")&&(data["Field A"]!="")
```

This only runs if Rule 1 was false, meaning "Yes" was selected. It marks the field valid only if the operator has entered text. Click **Valid** to set the status, colour, and a message.

![Screenshot 2025-11-12 at 4.01.39 pm](https://support.ofsystems.com/hs-fs/hubfs/Screenshot%202025-11-12%20at%204.01.39%20pm.png?width=618&height=190&name=Screenshot%202025-11-12%20at%204.01.39%20pm.png)

**Rule 3 — catch-all, mark as Invalid:**

```
1==1
```

This is only reached if the first two rules fail — meaning "Yes" was selected but **Field A** was left empty.

- **Mark form as:** Invalid (or Error, to prevent submission).
- **With message:** "This field is required when 'Yes' is selected."

![Screenshot 2025-11-12 at 4.04.38 pm](https://support.ofsystems.com/hs-fs/hubfs/Screenshot%202025-11-12%20at%204.04.38%20pm.png?width=670&height=225&name=Screenshot%202025-11-12%20at%204.04.38%20pm.png)

![Screenshot 2025-11-12 at 4.04.01 pm](https://support.ofsystems.com/hs-fs/hubfs/Screenshot%202025-11-12%20at%204.04.01%20pm.png?width=307&height=377&name=Screenshot%202025-11-12%20at%204.04.01%20pm.png)

---

#### **Test it**

Select "No" and leave **Field A** empty — it should pass. Select "Yes" and leave **Field A** empty — it should fail with your message. Select "Yes" and fill in **Field A** — it should pass.

**Rule 1:**

**![](https://support.ofsystems.com/hs-fs/hubfs/image-png-Nov-12-2025-05-09-29-2073-AM.png?width=670&height=174&name=image-png-Nov-12-2025-05-09-29-2073-AM.png)**

**Rule 2:**

**![](https://support.ofsystems.com/hs-fs/hubfs/image-png-Nov-12-2025-05-10-17-3821-AM.png?width=670&height=183&name=image-png-Nov-12-2025-05-10-17-3821-AM.png)**

**Rule 3:** Mark as INVALID (Catch-all).

![](https://support.ofsystems.com/hs-fs/hubfs/image-png-Nov-12-2025-05-10-31-6836-AM.png?width=670&height=196&name=image-png-Nov-12-2025-05-10-31-6836-AM.png)

- [Getting Started](https://support.ofsystems.com/getting-started?hsLang=en#main-content)

    - [Console: The Basics](https://support.ofsystems.com/getting-started?hsLang=en#console-the-basics)
    - [Analytics: The Basics](https://support.ofsystems.com/getting-started?hsLang=en#analytics-the-basics)
    - [Fusion Manager: The Basics](https://support.ofsystems.com/getting-started?hsLang=en#fusion-manager-the-basics)
    - [OFS-Flow Training : The Basics](https://support.ofsystems.com/getting-started?hsLang=en#ofs-flow-training-the-basics)
    - [OFS-Go](https://support.ofsystems.com/getting-started?hsLang=en#ofs-go)
    - [MayvnAI](https://support.ofsystems.com/getting-started?hsLang=en#mayvnai)
- [Help & Support](https://support.ofsystems.com/help-support?hsLang=en#main-content)

    - [Troubleshooting](https://support.ofsystems.com/help-support?hsLang=en#troubleshooting)
    - [OFS in a Box](https://support.ofsystems.com/help-support?hsLang=en#ofs-in-a-box)
    - [Routers](https://support.ofsystems.com/help-support?hsLang=en#routers)
    - [PLCs](https://support.ofsystems.com/help-support?hsLang=en#plcs)
- [Success with MayvnAI](https://support.ofsystems.com/success-with-mayvnai?hsLang=en)
- [Training Videos](https://support.ofsystems.com/training-videos?hsLang=en#main-content)

    - [Operator Console](https://support.ofsystems.com/training-videos?hsLang=en#operator-console)
    - [OFS Analytics](https://support.ofsystems.com/training-videos?hsLang=en#ofs-analytics)
    - [Fusion-Manager](https://support.ofsystems.com/training-videos?hsLang=en#fusion-manager)
    - [OFS-Flow](https://support.ofsystems.com/training-videos?hsLang=en#ofs-flow)
    - [OFS-Go](https://support.ofsystems.com/training-videos?hsLang=en#ofs-go)
- [How To Questions](https://support.ofsystems.com/how-to-questions?hsLang=en#main-content)

    - [Administration](https://support.ofsystems.com/how-to-questions?hsLang=en#administration)
    - [Operator Console](https://support.ofsystems.com/how-to-questions?hsLang=en#operator-console)
    - [Analytics](https://support.ofsystems.com/how-to-questions?hsLang=en#analytics)
    - [Fusion Manager](https://support.ofsystems.com/how-to-questions?hsLang=en#fusion-manager)
    - [Fusion Manager - Alerts & Services](https://support.ofsystems.com/how-to-questions?hsLang=en#fusion-manager-alerts-services)
    - [Flow](https://support.ofsystems.com/how-to-questions?hsLang=en#flow)
    - [Flow - Validations](https://support.ofsystems.com/how-to-questions?hsLang=en#flow-validations)
    - [Flow - Conditional Expression & Triggers](https://support.ofsystems.com/how-to-questions?hsLang=en#flow-conditional-expression-triggers)
    - [APIs](https://support.ofsystems.com/how-to-questions?hsLang=en#apis)
- [FAQs](https://support.ofsystems.com/faqs?hsLang=en#main-content)

    - [Operator Console](https://support.ofsystems.com/faqs?hsLang=en#operator-console)
    - [Fusion Manager](https://support.ofsystems.com/faqs?hsLang=en#fusion-manager)
    - [Analytics](https://support.ofsystems.com/faqs?hsLang=en#analytics)
    - [OFS-Flow](https://support.ofsystems.com/faqs?hsLang=en#ofs-flow)
- [Case Studies](https://support.ofsystems.com/case-studies?hsLang=en#main-content)

    - [Mavyn AI](https://support.ofsystems.com/case-studies?hsLang=en#mavyn-ai)
- [OFS Guides](https://support.ofsystems.com/ofs-guides?hsLang=en)
- [Webinars](https://support.ofsystems.com/webinars?hsLang=en)

[![](https://support.ofsystems.com/hs-fs/hubfs/Logo%20Medium_no%20words.png?width=128&height=68&name=Logo%20Medium_no%20words.png)](http://ofsystems.com)

Operations Feedback Pty Ltd

7/627 Chapel St, South Yarra, VIC 3123  
+61 3 8684 9859

<https://www.ofsystems.com/> <https://www.linkedin.com/company/operations-feedback-systems/> [mailto:support@ofsystems.com](mailto:support@ofsystems.com)

Copyright © 2025, Operations Feedback Systems Pty Ltd.