Skip to main content
Participant
June 7, 2024
Question

Radio button, then required fields

  • June 7, 2024
  • 2 replies
  • 512 views

I have a question about having a radio button and then required checkboxes.

I have a radio button with two options. If one option is selected, then the three following checkboxes are required by my client to check. If the other option is slected, the checkboxes are not required/optional. Is there a way to do this?

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
June 7, 2024

Be aware that the "required" property is only validated when the file is submitted, not when saved, printed, emailed, etc.

PDF Automation Station
Community Expert
Community Expert
June 7, 2024

Change the export values of the radio buttons to Required, and, Not Required.  Enter the following script as mouse up action in both radio buttons:

if(event.target.value=="Required")
{
this.getField("Check Box1").required=true;
this.getField("Check Box2").required=true;
this.getField("Check Box3").required=true;
}
else
{
this.getField("Check Box1").required=false;
this.getField("Check Box2").required=false;
this.getField("Check Box3").required=false;
}
Participant
June 7, 2024

these radio buttons are mutually exclusive so i only seem to be able to make them both required or not required. and then am i supposed to make the checkboxes or required or not? Thanks

PDF Automation Station
Community Expert
Community Expert
June 7, 2024

The radio buttons are mutually exclusive by having the same name and different export values.  Each is a widget child of that field.  The required property is field level property not a widget level property so it can't be different for each radio button in the series.  If you set it to required, and either is selected, it safisfies the requirement.  After you click one and save the file one or the other will always be selected (unless the form is reset).  I'm not sure what you are asking me.  What do you mean by "required" for the check boxes?  Do you mean the required property in the General tab of the properties is checked?  This script turns it on and off using the radio buttons.