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

Javascript Beginner

Community Beginner ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

320

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 , Nov 20, 2017 Nov 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

...

Votes

Translate

Translate
Community Expert ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

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 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
Community Beginner ,
Nov 21, 2017 Nov 21, 2017

Copy link to clipboard

Copied

LATEST

Thanks so much for your assistance!

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