Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

How to make atleast one to be selected on checkbox

Sandeep36
Tera Contributor

Hello,

I have below requirement,

User has to select atleast one checkbox. all these checkboxes are in a container, i made the container mandatory it did not work.

some one has soluton for it??

find_real_file.png

Thanks

12 REPLIES 12

SanjivMeher
Mega Patron

Hi Sandeep,



Check the below thread.



Re: Make Variable type 'Checkbox' mandatory


Hi Sandeep,



If this answered your question, Please mark it answered.


akashsrm100
Kilo Guru

What you need to do have all checkbox name in an arrey


    var sTypeofModifys=['checkbox1','checbox2','checkbox3'];


            var isSelected=false;


            for(var nIndex=0;nIndex<sTypeofModifys.length;nIndex++){


                    //alert(g_form.getValue(sTypeofModifys[nIndex]));


                    if(g_form.getValue(sTypeofModifys[nIndex])=='true'){


                            isSelected=true;


                            //alert(isSelected);


                            break;


                    }


            }


     


      if(isSelected==false){


              alert('Please check atleast 1 checkbox');


              return false;


      }


You need to create a new label variable and arrange all the remaining check boxes in order below the label (Use order field to align). After this, add a UI policy based on your condition that checks if any one check box is selected or else set the UI policy on the label variable mandatory. With this logic the user will be forced to select a value in the checkbox.



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response