Skip to main content
Participant
February 1, 2018
Answered

Help with Yes/No Radio Button - Required Field

  • February 1, 2018
  • 1 reply
  • 6006 views

Hi,

Trying to make my forms more dynamic. I am working on a summer camp registration form and there are some fields that are required to be completed based on the users selection of either Yes or No.

Example, Are there any food allergies? Yes - make the field listing the food allergies required; No - move to the next question

I have other questions based on this condition too. Is there any way I can do this? Using Acrobat Pro DC. Please help - it's greatly appreciated!

This topic has been closed for replies.
Correct answer Thom Parker

All versions of Acrobat and Reader going back many years work the same as far as this type of scripting. And the same is true for Acrobat Professional versions, you can enter this type of script in any of them.

To use a Yes/No radio button group to set other fields to required, takes two scripts, one on each button.  The Yes button sets the fields to required, and the No button resets the required property.

I don't know you field names so you'll have to rename them in the script.

Put this code in the MouseUp Action for the Yes Button

this.getField("ReqFld1").required = true;

this.getField("ReqFld2").required = true;

etc. (for each field)

Put this code in the MouseUp Action for the No Button

this.getField("ReqFld1").required = false;

this.getField("ReqFld2").required = false;

etc. (for each field)

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 1, 2018

All versions of Acrobat and Reader going back many years work the same as far as this type of scripting. And the same is true for Acrobat Professional versions, you can enter this type of script in any of them.

To use a Yes/No radio button group to set other fields to required, takes two scripts, one on each button.  The Yes button sets the fields to required, and the No button resets the required property.

I don't know you field names so you'll have to rename them in the script.

Put this code in the MouseUp Action for the Yes Button

this.getField("ReqFld1").required = true;

this.getField("ReqFld2").required = true;

etc. (for each field)

Put this code in the MouseUp Action for the No Button

this.getField("ReqFld1").required = false;

this.getField("ReqFld2").required = false;

etc. (for each field)

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
February 22, 2018

Once the field are required how do I make an group contingent upon that yes or no?  For example, If yes, click... If no, click.... but I do not want the no options operable when it is yes.  Can you help me

Thom Parker
Community Expert
Community Expert
February 22, 2018

Please provide a clearer explanation.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often