Skip to main content
Participant
July 19, 2018
Answered

Need help with Forms

  • July 19, 2018
  • 2 replies
  • 936 views

I'm working on creating a form for people at work, however i'm having difficulties making it the way I want it. If i have a question that states

" Have you ever worked in a similar field?"

I used radio buttons for Yes or No

Following question is "If yes, please indicate the following"

Name of company with a text field

Description of company with a text field

Is there any way to enforce whomever clicks yes, to mandate them to answer the "If yes, please indicate the following" questions?

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

So that's easy. Put this script on the MouseUp event of the Yes checkbox. (If this Yes is not a check box then a different script will be needed). Note that the "2ndQuestion" field name in the script is just a placeholder. You'll need to replace it with the real name of the field.

this.getField("2ndQuestion").required = (event.target.value !="Off");

This script will only work in PDF viewers that implement the Acrobat JavaScript model. In other viewers there is no way to perform this action.

2 replies

Participant
September 10, 2023

I need this program to Edit PDF files and create invoices which I wa able to do just a month or so ago? What happened to my subscription?

Thom Parker
Community Expert
Community Expert
July 19, 2018

It depends on how the form is used. You can make it so the form won't submit if the fields are not filled. But not all forms are submitted, so you can also write scripts to force the cursor focus to remain on fields, but this is generally a bad practice.  A better strategy is to highlight the fields in some way to let the user know that they need to be filled out. An additional method is to show a popup warning message that indicates the fields must be filled out. However, this message needs some type of trigger event. Good events for this include saving, printing, and submitting. 

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

Thanks for replying and helping, yes these forms are used for submitting electronically. My issue is if i make the 2nd question a required field, but the person who fills out the form answers no - they're unable to submit the form. Is there any way I am able to make the 2nd question only required if the person filled out yes to the previous question?

thank you in advance

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
July 20, 2018

So that's easy. Put this script on the MouseUp event of the Yes checkbox. (If this Yes is not a check box then a different script will be needed). Note that the "2ndQuestion" field name in the script is just a placeholder. You'll need to replace it with the real name of the field.

this.getField("2ndQuestion").required = (event.target.value !="Off");

This script will only work in PDF viewers that implement the Acrobat JavaScript model. In other viewers there is no way to perform this action.

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