Skip to main content
lucy61176
Participating Frequently
December 29, 2017
Answered

Require certain fields based on combo box selection

  • December 29, 2017
  • 1 reply
  • 1640 views

I have created a dynamic form in Acrobat DC where selecting a button will make certain fields required and/or suggested (using green border around the field). I was able to do this successfully with everything but the combo box. I need to be able to make certain fields (text and checkboxes) required or suggested based on the selection in the combo box. I haven't been able to find exactly what I'm looking for googling this. Any help is greatly appreciated!

This topic has been closed for replies.
Correct answer try67

Here is the file: f00476 12 20 17 DRAFT.pdf - Google Drive

I'm trying to get the basic code and instructions so that I can use it to create different scenarios for the various selections in the combo box.


OK, I see the issue. You need to use the display value instead of the export value when using event.value.

So instead of:

if (event.value == "1")

Use:

if (event.value == "A-FSET")

1 reply

try67
Community Expert
Community Expert
December 29, 2017

There shouldn't be an issue to do it, although it's possible the built-in required fields validation will ignore these fields.

lucy61176
lucy61176Author
Participating Frequently
December 29, 2017

Sorry, but I don't know how. I am only able to get it to work if I choose something from the combo box, go to another field, and go back to the combo box. When I click on the dropdown arrow, that is when it works. The javascript I have under Mouse Up is:

var PrimaryCARESAccess = this.getField("PrimaryCARESAccess");

var IMDropdown = this.getField("IMDropdown");

if (PrimaryCARESAccess.value == "1") {IMDropdown.required = true;}

try67
Community Expert
Community Expert
December 29, 2017

Use this code as the validation script of the drop-down:

var IMDropdown = this.getField("IMDropdown");

if (event.value == "1") {IMDropdown.required = true;}

Also, make sure to tick the option to commit the selected value immediately, under Properties - Options.