[RESOLVED]JQuery iterate checkboxlist


I have a checkboxlist in a createuserwizard. I am trying to create a custom validator for it. But for some reason I am getting an error in my javascript. It gets the element but when I try to get all the inputs of the checkboxlist it gives an error.

Any help would be really appreciated.

function ValidateServiceCheckboxlist(source, args) {

            var chklist = '<%= CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("chkCompanyService").ClientID %>';
            var chklist23 = document.getElementById('<%= "CreateUserWizardStep1.ContentTemplate.chkCompanyService.ClientID"  %>');
            var chkListInputs = chklist.getElementsByTagName("input");

            for (var i = 0; i < chkListInputs.length; i++) {
                if (chkListInputs[i].checked) {
                    args.IsValid = true;
            args.IsValid = true;

This gives the error Error: Unable to get value of the property ‘getElementsByTagName’: object is null or undefined

"chkList" is a string, it doesn’t have a getElementsByTagName method.  Did you mean to use chkList23 instead?

var chkListInputs = chklist23.getElementsByTagName("input");

Leave a Reply