• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with Yes/No Radio Button - Required Field

New Here ,
Feb 01, 2018 Feb 01, 2018

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

4.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 01, 2018 Feb 01, 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 t

...

Votes

Translate

Translate
Community Expert ,
Feb 01, 2018 Feb 01, 2018

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

Please provide a clearer explanation.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

I am creating a form like the one shown below:

Vehicle:  Yes    No

If Yes, which type:  Truck      SUV    Sedan

If no, will there be a car allowance required?

If the Yes button is click I want to restrict the submitter from answering in the no section.  and if they select no for the vehicle I want to restrict them for selecting the type.  I would like to make one contingent upon the other.  If, then statement.  Does that make sense?  Thanks, Layne

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

What you need to do is to set the fields in the Yes and No sections to Read Only. Then use the Yes/No button scripts to  enable/disabled the fields in exactly the same way the "required" property is set.

For example:

this.getField("ReqFld1").readOnly= false; // or true depending on the button pushed.

Both the "required" and "readOnly" properties need to be balanced. So when Yes is clicked the field in the Yes section are marked as required and readOnly is set to false. But in the same script the fields in the No section need to have required set to false and readOnly set to true.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

LATEST

thank you I will try that.  I appreciate you and your time. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines