I am trying to get the count of selected items from an asp listbox using jquery but can't figure out how to do it. this is how I have it as of now, but I get "Cannot get property length of undefined or null reference" on selectedOptions property. var lb
fills with
objectHtmlSelectElement,
so that seems right.
function CheckSelectionCount(sender, args) {
var lb = document.getElementById(sender.controltovalidate);
var count = lb.selectedOptions.length;
args.IsValid = count >= 1 && count <= 5;
}
Many similar questions remedy this using a selector combined with the :selected attribute, but I think I need to leverage the sender argument and store it in a variable.
I'm sure this will be easy for the experts on here! Thanks in advance