Skip to main content
aprild49548367
Known Participant
March 27, 2018
質問

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

  • March 27, 2018
  • 返信数 2.
  • 1556 ビュー

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

このトピックへの返信は締め切られました。

返信数 2

aprild49548367
Known Participant
March 27, 2018

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

aprild49548367
Known Participant
March 28, 2018

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();}

aprild49548367
Known Participant
March 29, 2018

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.


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();}

Inspiring
March 27, 2018

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