Skip to main content
CHP HR
Participant
July 2, 2024
Question

Radio Button Required Field

  • July 2, 2024
  • 1 reply
  • 792 views

Hello Community

I have multiple questions on an adobe form that are radio button.

Three fields, Yes, No, If yes explain

How can I make this whole question a required field, but not require "If yes", when no is selected. Here is the example:

 

I have seen answers posted but they tend to be a tad confusing. I am not well versed in scripting. And which goes where. I am using Adobe Acrobat Cloud version I know how to add the script  just need to know if required or read only need to be checked for each and what script goes with which button

 

What script goes in "Group1"  yes?

 

What Script goes in "Group1" no?

 

What Script goes in "If yes"?

 

Thank you

This topic has been closed for replies.

1 reply

Karl Heinz  Kremer
Community Expert
Community Expert
July 2, 2024

You only need a script for the "if yes" field. Let's assume that the export values for your "YesNoGroup" are set to "Yes" and "No" (you do that on the Options tab as "Radio Button Choice"), the following script for your text field should result in the desired behavior:

 

// get the value of the radio buttons
var yesNo = this.getField("YesNoGroup").value;

if (yesNo == "Yes") {
   event.target.required = true;
}
else {
   event.target.required = false;
}

 

CHP HR
CHP HRAuthor
Participant
July 2, 2024

wow much appreciated I will give it a whirl!