• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

563

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

Community Expert , Mar 10, 2021 Mar 10, 2021

Try this:

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

 

 

 

Votes

Translate

Translate
Community Expert , 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");

Votes

Translate

Translate
Community Expert ,
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; 

 

 

 

Votes

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
Community Expert ,
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");

Votes

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