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

Required narrative if any check boxes are selected

New Here ,
Apr 29, 2024 Apr 29, 2024

I am trying to create a fillable document with multiple tiers with check boxes, and if any of the check boxes in that tier is selected, I would like the narrative field below that tier to become required. 

For example: 

Tier 1:

  • Selection 1
  • Selection 2
  • Selection 3
  • Selection 4
  • Selection 5
  • Tier 1 Narrative

 

Tier 2:

  • Selection 6
  • Selection 7
  • Selection 8
  • Selection 9
  • Selection 10
  • Tier 2 Narrative

 

What I'm looking for is if any of Sections 1-5 are selected, Tier 1 Narrative becomes required, and if any of Selections 6-10 are selected, tier 2 narrative becomes required, and so on and so forth. 

TOPICS
PDF , PDF forms
187
Translate
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 ,
Apr 29, 2024 Apr 29, 2024

Let's say checkboxes are named "Selection 1" to 5, use this as custom calculation script of Tier 1 text field:

var req = false;
for(var i=1; i<=5; i++){
var f = this.getField("Selection "+i).valueAsString;
if(f !== "Off")
req = true;}
event.target.required = req;

For other tiers, adjust loop like this for tier 2: for(var i=6; i<=10; i++){

Translate
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 ,
Apr 29, 2024 Apr 29, 2024
LATEST

Be aware the required property is only enforced when the file is submitted, not when saved, printed, emailed, etc.

Translate
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