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

How to require questions with Yes or No radio buttons be answered

New Here ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

I have created a form that includes two questions with Yes or No radio buttons for answers.  I would like to make them required so that the first question has to be answered before moving on to the next question.  Is there a way to do that?

Ex: Is the applicant is an individual?  Yes  or   No  (I have named this set of radio buttons "HMDA"). I don’t want people to tab through this question without answering it first.  Once it is answered I would like them to be directed to the next question which is "Is the applicant an entity?"  Yes   or   No (I have named this set of radio buttons "BeneficialOwner").

Thanks

TOPICS
Acrobat SDK and JavaScript , Windows

Views

538

Likes

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
LEGEND ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

You have to write some custom JavaScript code to test that the radio button does not have a value of "Off" and then if that is true unlock the next fields.

Disabling (graying-out) form fields with Acrobat 7 and 8

Likes

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 ,
Mar 27, 2018 Mar 27, 2018

Copy link to clipboard

Copied

Thanks for responding but I'm really a beginner with this.  Can you tell me what the JavaScript would say/look like?

Likes

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 ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Below are the questions from my form.  I want to force the applicant to answer each question without being able to skip over them.  I wrote the below code but it doesn't work properly.  If the applicant tries to skip the first question an alert will appear letting them know they have to answer the question.  When they click ok to dismiss the alert - if they answer yes to the first question it works fine and they can move on to the second question.  However, when they click ok to dismiss the alert - if they answer No to the first question then it just makes the alert pop-up again before the applicant can move on.

When I try to apply the same script (with different field names) to the second question it wants to make the alert from the first question appear with the alert for the second question.     

Script for First Question:

if (getField("HMDA").value="Off")
{app.alert("If the applicant is an individual, is the collateral offered a
residential dwelling?  Please select
either Yes or No", 3);getField("HMDA").setFocus();}

Script for second question:

if (getField("BeneficialOwner").value="Off")
{app.alert("If the applicant is an individual, is the collateral offered a
residential dwelling?  Please select
either Yes or No", 3);getField("BeneficialOwner").setFocus();}

Likes

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 ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

This is not a good idea... But if you really want to do it you need to use the correct operator.

The "=" operator is for value assignment. You need to use "==".

Also, you can't include line-breaks in a string like that.

Likes

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 ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

I changed it the below.  I didn't notice it doing anything differently and I don't think I know what you are talking about when you say line-break.  Is there a better way for me to require the fields to be answered?

if (getField("HMDA").value=="Off"){app.alert("Please select either Yes or No", 3);getField("HMDA").setFocus();}

Likes

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 ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

Is the file being submitted back to you? If so, add this validation to the Submit button.

Likes

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 ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

Unfortunately, it is not being submitted.  The applicant has to print and sign it. 

I did try a different route...  I made Yes the default answer in the first question and then added the script below to create a pop-up for the applicant to confirm their answer.  However, if they change their answer to No in the pop-up it didn't change the answer on the form.  Any suggestions on how to make it change the answer on the form if they change the answer in the pop-up?

var dialogTitle = "Please Confirm";

var defaultAnswer = "Yes";

var reply = app.response ("Please confirm that the applicant is an individual and the collateral offered is a residential dwelling.", dialogTitle, defaultAnswer);

Likes

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
Engaged ,
May 10, 2018 May 10, 2018

Copy link to clipboard

Copied

LATEST

This is bad, do not put default answers in a required field.  Users will miss them.  And do not ask them to confirm with a dialog box either, everyone just presses "OK" to any dialog that pops in their face.

Since Radio button do not have a Calculation tab, just use an invisible text field and put a script that hides the second set of radio buttons if a choice is not made is the first set inside its custom calculation

Likes

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