Require text field conditional on drop down menu selections

New Here ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

I have a form with a drop down menu.  If a user selects "Extender" or "Change Order" from the dropdown menu, I want to make a text field required to be filled in before they can submit the form.  I have the javascript that follows in the custom validation script box of the dropdown properties.

 

this.getField("TargetProject").required = (event.value=="Extender"); 

 

This script I can make work for one option only. How can it be modified to work with a second option?

My list of options is the following:

Blank (default)

New

Change Order

Extender

Contract

 

The two bold options need to trigger the required text field.

Below are screenshots of the dropdown properties boxes.Dropdown.jpg

Any help would be greatly appreciated.

TOPICS
JavaScript, PDF forms

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Adobe Community Professional , Mar 10, 2021 Mar 10, 2021
Try this:this.getField("TargetProject").required = event.value == "Extender" || event.value == "Change Order" ? true : false;

Likes

Translate

Translate
Adobe Community Professional , Mar 10, 2021 Mar 10, 2021
You don't need the last part of the code. This is sufficient: this.getField("TargetProject").required = (event.value == "Extender" || event.value == "Change Order");

Likes

Translate

Translate
Adobe Community Professional ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Try this:

this.getField("TargetProject").required = event.value == "Extender" || event.value == "Change Order" ? true : false; 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

LATEST

You don't need the last part of the code. This is sufficient:

this.getField("TargetProject").required = (event.value == "Extender" || event.value == "Change Order");

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines