Elena Posted June 28, 2014 Report Share Posted June 28, 2014 Hello there, How can I limit the selection done through multi-select listbox to a certain number? When the user exceeded I would like to show a message "selection is limited to 10". Help is appreciated. Elena Quote Link to comment Share on other sites More sharing options...
0 MayMusic Posted December 23, 2016 Report Share Posted December 23, 2016 Try this in the footer of the submission page <script type="text/javascript"> /* "fieldName" is the variable name for the listbox type form element field. */ var fieldName = "InsertRecordFirst_Name"; var x=document.getElementsByName(fieldName); x[0].multiple=true; var el = document.getElementsByTagName('select')[0]; document.getElementById('Submit').onmouseover= function (){ var el = document.getElementsByTagName('select')[0]; getSelectValues(el); } function getSelectValues(select) { var result = []; var options = select && select.options; var opt; for (var i=0, iLen=options.length; i<iLen; i++) { opt = options[i]; if (opt.selected) { result.push(opt.value || opt.text); } } if (result.length>10){ alert('Select max 10 options for First Name'); return false; } } </SCRIPT> Replace InsertRecordFirst_Name with the actual listbox ID value Quote Link to comment Share on other sites More sharing options...
0 Kurumi Posted November 30, 2023 Report Share Posted November 30, 2023 Hi - sharing this forum post if you would like to get the Display values in the listbox Quote Link to comment Share on other sites More sharing options...
0 PotatoMato Posted March 14 Report Share Posted March 14 Hi! Just to update, Caspio has already added an article to limit selection on multi-select listbox: https://howto.caspio.com/tech-tips-and-articles/setting-the-maximum-number-of-listbox-selections-in-forms/ -Potato Quote Link to comment Share on other sites More sharing options...
Question
Elena
Hello there,
How can I limit the selection done through multi-select listbox to a certain number?
When the user exceeded I would like to show a message "selection is limited to 10".
Help is appreciated.
Elena
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.