Skip to main content
Known Participant
November 20, 2017
Answered

Javascript Beginner

  • November 20, 2017
  • 2 replies
  • 507 views

I have developed a pdf form with various checkboxes in Acrobat Pro.  In one section, the response to a question is a YES (The form field is CBY) or NO (The form field is CBN)checkbox.  How do I require at least one of the checkboxes to be checked before submitting the form.  In another section, I have a checkbox for OTHER (The form field is Check Box18) with a space to enter text in Text32 (The form field is Text32).  How do I require a text to be completed if the 'Other' checkbox is checked.

Please provide step by step since this is foreign to me.  Thanks.

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

This kind of form level validation is always problematic, even for text fields if you need to validate to something other than empty.

By submit I'm assuming you mean the user has to press a submit button?

If so, then you can take control of this process with a script on the button.  However, this solution is for more complicated validation, in your case there are a couple of much simpler things you can do.

1.  For requiring one of the two check boxes be checked, Why not use Radio buttons? You can set the Radio button group to required and the default Submit Validation will check it for you, just like the text boxes

2. For the field enabled with a check box, put a script on the check box MouseUp event that marks the field as required.

getField("Text32").required = event.target.isBoxChecked(0);

2 replies

Known Participant
November 21, 2017

Thanks so much for your assistance!

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
November 20, 2017

This kind of form level validation is always problematic, even for text fields if you need to validate to something other than empty.

By submit I'm assuming you mean the user has to press a submit button?

If so, then you can take control of this process with a script on the button.  However, this solution is for more complicated validation, in your case there are a couple of much simpler things you can do.

1.  For requiring one of the two check boxes be checked, Why not use Radio buttons? You can set the Radio button group to required and the default Submit Validation will check it for you, just like the text boxes

2. For the field enabled with a check box, put a script on the check box MouseUp event that marks the field as required.

getField("Text32").required = event.target.isBoxChecked(0);

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