Skip to main content
Known Participant
March 14, 2025
Question

Creating a Button to Flag Required Radio Buttons

  • March 14, 2025
  • 1 reply
  • 2295 views

I am creating a form for a design company; there are several radio buttons that are required for submission. I want to create a button that when clicked, shows nothing if all required radio buttons are selected. If required radio buttons have not been selected, I want a pop up stating "Please select all required radio buttons" to appear. I have searched forums for days and nothing seems to be working properly.

1 reply

Thom Parker
Community Expert
Community Expert
March 14, 2025

Radio button groups (and check boxes) have a value of "Off" when unselected.  For example, if one of the radio button groups is named "Group1", then this code (on a button) could be used to validate a selection.

 

if(this.getField("Group1").value == "Off")

     app.alert("Please select an entry for the Group 1 Radio Buttons");

 

You can read more about radio buttons and checkboxes here:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
March 14, 2025

That didn't work. The radio grouping is Group3.

 

try67
Community Expert
Community Expert
March 14, 2025

You need to add the submit command after the if-statement, like this:

 

 

if(this.getField("Group3").value == "Off")
     app.alert("Please select an entry for the Group 1 Radio Buttons");
else this.mailDoc({cTo: "me@email.com"});

 

 

And just saying "it doesn't work" is not very useful to us. What exactly happens when you click the button? Is there an error message in the JS Console? Does anything happen at all? Be more specific, please.