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

Multiple radio button selection to habilitate a text field

New Here ,
Sep 17, 2024 Sep 17, 2024

Copy link to clipboard

Copied

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

Views

121

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 , 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 
...

Votes

Translate

Translate
New Here ,
Sep 17, 2024 Sep 17, 2024

Copy link to clipboard

Copied

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

 

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

Copy link to clipboard

Copied

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;

 

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

Copy link to clipboard

Copied

LATEST

Thank you very much!!

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