How to make multiple "checkbox" variables mandatory.........
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello,
Please how can I make multiple "checkbox" variables mandatory on a request form. Basically, there are about 6 checkbox variables and each of them must equal to "TRUE" for the form to be submitted. If one or two of those checkbox are not checked, the system must not allow submission until they are all checked. How do I do this please?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
something like this in onSubmit catalog client script
function onSubmit() {
// List your checkbox variable names here
var checkboxes = [
'checkbox_var_1',
'checkbox_var_2',
'checkbox_var_3',
'checkbox_var_4',
'checkbox_var_5',
'checkbox_var_6'
];
// Check if all are true (checked)
for (var i = 0; i < checkboxes.length; i++) {
if (g_form.getValue(checkboxes[i]).toString() !== 'true') {
alert('Please check all required checkboxes before submitting.');
return false; // block submission
}
}
return true; // all checked, allow submit
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Ankur Bawiskar ,
Thanks for your supports. However, I have tried it but it doesn't work please. Is there any other way we can make it work please?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
41m ago
script I shared should work fine and will check if all checkboxes are true or not
what debugging did you do?
did you replace your variable names in that above script?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3m ago