- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 09:50 AM
I have this client script that should only allow 1 checkbox to be selected, but when I test it still lets me select I agree or I disagree. Can someone help me out?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 01:05 PM
Another thought is to possibly just ask if they Agree and then have a Yes/No drop down or if it is important that they choose agree or disagree use a multi-Choice box. Both these options could be made mandatory unlike check boxes and they can only chose one. Example of a multi-choice field.
You could also use a select box with options I Agree or I Disagree.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:03 PM
the 2nd check box is i_agree_1 and i_disagree_1.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:20 PM
I'm not sure how my code could be causing that. I should be only looking at the one set of check boxes. Did you change it in any way to make it look at all 4?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:43 PM
No I copy and paste your script in.
1st check box variable names : i_agree and i_disagree
2nd check box variable names: i_agree_1 and i_disagree_1.
Thanks,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:43 PM
function onSubmit() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('i_agree') == 'true' && g_form.getValue('i_disagree') == 'true') {
alert('You can only select one option');
return false;
} else if (g_form.getValue('i_agree') == 'false' || g_form.getValue('i_disagree') == 'false') {
alert('you must select an option');
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 12:59 PM
Ok I just created a simple form in my PDI with 4 check boxes. I made the display name almost the same as the variable name except no user scores between letters.
I used the following code and it works without issues.
function onSubmit() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('i_agree') == 'true' && g_form.getValue('i_disagree') == 'true') {
alert('you can only choose one option first set of checkboxes');
return false;
} else if (g_form.getValue('i_agree') == 'false' && g_form.getValue('i_disagree') == 'false') {
alert('you must choose one option first set to checkboxes');
return false;
} else if (g_form.getValue('i_agree_1') == 'true' && g_form.getValue('i_disagree_1') == 'true') {
alert('you can only choose one option second set of checkboxes');
return false;
} else if (g_form.getValue('i_agree_1') == 'false' && g_form.getValue('i_disagree_1') == 'false') {
alert('you must choose one option second set to checkboxes');
return false;
}
}