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

Multiple radio button selection to habilitate a text field

Community Beginner ,
Sep 17, 2024 Sep 17, 2024

Can someone please assist in script that would make a text field called PLAN mandatory to fill up with the following conditions?: 

If 5 or more of the radio buttons in the RED column are selected, the text PLAN has to be mandatory

Also

If 7 or more of the BLUE column are selected, the text field PLAN has to be mandatory

All sets of radio button are called in groups as per the first column, the RED column has a value of 1 and the BLUE an option of 5.

I truly appreciate your help. And Thanks!!

 

2024-09-18 08_28_13-PPG_BC_TEMPLATE.pdf - Adobe Acrobat Pro.png

TOPICS
JavaScript , PDF forms
404
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
1 ACCEPTED SOLUTION
Community Expert ,
Sep 18, 2024 Sep 18, 2024

I assume numbers on the left are radio button names (1.1, 1,2...etc), use this script in "PLAN" field as custom calculation script under 'Calculate' tab:

 

var fields = ["1.1","1.2","1.3","1.4","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","5.1","6.1","6.2","6.3","6.4","6.5","7.1","8.1"];
var red = 0;
var blue = 0;
for(var i=0; i<fields.length; i++){
 var f = this.getField(fields[i]).valueAsString;
 if(f === "1")red++;
 if(f === "5")blue++;}

event.target.required = (red>=5 || blue>=7) ? true : false;

 

View solution in original post

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 Beginner ,
Sep 17, 2024 Sep 17, 2024

I forgot to clarify that all 20 questions have to be selected in one of the columns with the radio buttons.

 

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 ,
Sep 18, 2024 Sep 18, 2024

I assume numbers on the left are radio button names (1.1, 1,2...etc), use this script in "PLAN" field as custom calculation script under 'Calculate' tab:

 

var fields = ["1.1","1.2","1.3","1.4","2.1","2.2","2.3","3.1","3.2","3.3","4.1","4.2","5.1","6.1","6.2","6.3","6.4","6.5","7.1","8.1"];
var red = 0;
var blue = 0;
for(var i=0; i<fields.length; i++){
 var f = this.getField(fields[i]).valueAsString;
 if(f === "1")red++;
 if(f === "5")blue++;}

event.target.required = (red>=5 || blue>=7) ? true : false;

 

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 Beginner ,
Sep 18, 2024 Sep 18, 2024
LATEST

Thank you very much!!

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