Copy link to clipboard
Copied
I have created a form in Acrobat Pro that contains an E-mail button so the form can be e-mailed, however there are some fields (radio buttons) that are required to be completed before the form can be e-mailed. I have made this requirement within the Radio Button Properties, under the General tab, checking the Required checkbox.
I have a group of 7 radio buttons named Housing. One of the radio button statements is What type of housing does the family have: there are two radio buttons choices that follow that statement named HousingType; the two choices are Permanent and Temporary.
Is it possible to do the following? If the radio button for What type of housing does the family have: is selected, I would like to have the two radio buttons named HousingType to be required…but with javascript – not by checking the Required checkbox in the properties for HousingType.
I tried this already but what happened was if another radio button for Housing was selected I could not e-mail the form because a choice was not made for the Required radio buttons for HousingType of Permanent or Temporary.
The HousingType radio buttons are only relevant/needed if the radio button for the Housing statement What type of housing does the family have: is selected.
Please let me know if this is possible, and if so what would the javascript be.
Thank you, Jamie
Copy link to clipboard
Copied
As 'Mouse UP' event of "What type of housing does the family have:" button use this:
if(event.target.value == "What type of housing does the family have:")
this.getField("HousingType").required = true;
TIP:
You should also add script to other buttons to make those fields not required if user change his mind and select another button instead.
If you decide to do that, use this script instead in all 7 "Housing" buttons as 'Mouse UP' event:
this.getField("HousingType").required = event.target.value == "What type of housing does the family have:" ? true : false;
Copy link to clipboard
Copied
As 'Mouse UP' event of "What type of housing does the family have:" button use this:
if(event.target.value == "What type of housing does the family have:")
this.getField("HousingType").required = true;
TIP:
You should also add script to other buttons to make those fields not required if user change his mind and select another button instead.
If you decide to do that, use this script instead in all 7 "Housing" buttons as 'Mouse UP' event:
this.getField("HousingType").required = event.target.value == "What type of housing does the family have:" ? true : false;
Copy link to clipboard
Copied
This will work, but only until you reset the form, and then the required fields will remain so, even when the radio-button is no longer selected. That's why I prefer to use a calculation script for such tasks. It also makes it easier since you can control it all from one place, and don't have to apply a script to multiple fields.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more