How to limit the selection of choice list up to 3 in checkbox
Options
- 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:
- Labels:
-
Customer Service Management
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 01:27 AM
create 6 onChange scripts on the 6 checkboxes and add the below code in all
var checkbox = ['checkbox1', 'checkbox2', 'checkbox3','checkbox4','checkbox5','checkbox6'];
var chkarr = {};
var count= 0;
for(var i=0;i<checkbox.length;i++){
chkarr[checkbox[i]] = g_form.getValue(checkbox[i]);
}
for (var key in chkarr){
if(chkarr[key] == 'true'){
count = count + 1;
}
if(count == 3){
for (var key1 in chkarr){
if(chkarr[key1] == 'false')
g_form.setReadOnly(key1,true);
}
}
else{
for (var key1 in chkarr){
g_form.setReadOnly(key1,false);
}
}
}