How to limit the selection of choice list up to 3 in checkbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 11:45 PM
Hello Developers,
I have a requirement where I used 6 checkboxes in the catalog item, but I have to restrict the user to select the utmost 3, please let me know how to achieve this.
Thanks in advance,
Akhil.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 11:55 PM
Hello Sai,
Please go through below blog.
https://www.servicenowguru.com/scripting/client-scripts-scripting/checkbox-variables-mandatory/
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 12:10 AM
Hello Harshal,
Thanks for your kind reply, but that blog will not suffice my requirement, the user does not want to select a minimum of 3 but can select up to 3. Please let me know if u know how to achieve this.
Thanks,
Akhil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 12:01 AM
Hello,
You can write client script in catalog item.
If answer is helpful please mark correct and helpful!
Thanks,
Pratiksha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 12:12 AM
Hi
Check this samplle code
var checkboxes = ['checkbox1', 'checkbox2', 'checkbox3', 'checkbox4'];
var count ;
for (var i = 0; i < checkboxes.length; i++) {
if (g_form.getValue(checkboxes[i]) == 'true') {
count = count +1;
break;
}
}
if (count > 3) {
g_form.addErrorMessage('You can't select all');
return false;
}
Regards
Pranav