UI Script to require at least one in a list of checkboxes be checked for form to be submitted

llbcdl
Giga Contributor

I am working on a donations form and I have a list of check boxes, at least one needs to be checked for the form to be submitted. I'd like a notice to popup on submit if the user did not select at least one checkbox.

find_real_file.png

I'm thinking a UI script on submit would do the trick but I fall short on how to write the section to check if at least one of the boxes is checked.

I found this in the question: onSubmit client script to prevent form submission

function onSubmit() {

if(g_form.getValue('ad_domain') == 'YES' || g_form.getValue('ad_domain') == 'YESb' && g_form.getValue('question_choice') == 'incorrect_info'){}

  if(g_form.getValue(user_confirm') == 'false' ){ //this is the checkbox

  alert('Please be sure to check the box before submitting a ticket.');

  return false;

}

}

Kinda does the trick but it is looking at specific check boxes to be checked.

8 REPLIES 8

Pedro Lopez
Kilo Guru

Hi,

If at least one checkbox needs to be checked before submit, it means it should be Mandatory. Follow these steps:

 

1. Right-Click in your first checkbox

2. Click on "Configure Variable"

3. Once you are inside of your variable, select "Selection Required"

4. CheckBoxes are Mandatory

 

Hope this helps,

Pedro Lopez

Hi Pedro,

Sorry if I wasn't clear. The requester needs to select at least one of the check boxes but not all check boxes. I don't want to make them all mandatory. The concern is the requester will complete the request without specifying at least one of the check boxes.

LLBCDL

llbcdl
Giga Contributor

I didn't realize check boxes worked that way. That was easy.

Thank you!

llbcdl
Giga Contributor

Actually that makes them all mandatory. I want the requester to select at least one but not all. My concern is that the requester will not select any.