Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
wow much appreciated I will give it a whirl!
Copy link to clipboard
Copied
I did add this script to "Text1" but when i chose "yes" option, and deliberately didnt add text in "text 1" it did not flag it as required field when i hit submit button. I am sure it is me missing something.
Buttons are called "Group1"
Yes is called "Text1"
You mention export value. there is no option for export value as there are in check boxes
thanks for your patience with this newbie scripter!
Copy link to clipboard
Copied
PS the screen capture cut it off but it does say:
// get the value of the radio buttons
var yesNo = this.getField("Group1").value;
if (yesNo == "Yes") {
event.target.required = true;
}
else {
event.target.required = false;
}
Copy link to clipboard
Copied
Do you get any error messages in the JavaScript console (Ctrl-J on Windows or Cmd-J on macOS)? Does the field in question get the red outline that indicates that it is a required field?
Copy link to clipboard
Copied
I notice you have a lower case y in "yes" in your description. It could be a typo, but these values are case sensitive. If your export value is "yes" instead of "Yes", it won't work.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now