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 Meekeee Posted 22 hours ago Report Share Posted 22 hours ago 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...
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
2 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.