开发者

Validation of Checkbox in Listview Control by Jquery/Javascript?

开发者 https://www.devze.com 2023-02-11 12:51 出处:网络
I am trying to validate the checkbox which is one of the items in ListView control. I have the button to check so I define the ClientClick function on the button and wrote JavaScript code.

I am trying to validate the checkbox which is one of the items in ListView control.

I have the button to check so I define the ClientClick function on the button and wrote JavaScript code.

But It didn't work. Display the lstViewtest object null.

    function btnclick() {
        var listview = document.getElementById('<%=
 lstviewtest.FindControl("tableItem").ClientID %>');
                
        for (var i = 0; i < listview.rows.length; i++) {
            va开发者_StackOverflowr inputs = listview.rows[i].getElementsByTagName('input');
            for (var j = 0; j < inputs.length; j++) {
                if (inputs[j].type === "checkbox" || inputs[j].type === "checkboxsend")
                    if (inputs[j].checked)
                        return true;
            }
            alert("Please select at least one");
            return false;
        } 
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消