Validating checkboxes present inside gridview with Javascript

前端 未结 1 1268
-上瘾入骨i
-上瘾入骨i 2021-01-29 03:43

I have 2 checkboxes in a GridView. I want to validate them with JavaScript. This is my aspx code...


                     


        
1条回答
  •  借酒劲吻你
    2021-01-29 03:54

    MyGridView = document.getElementById('<%= this.MyGridView.ClientID %>');
    var Inputs = MyGridView.getElementsByTagName("input");
    var chkBox = "chkExists";
    for(var n = 0; n < Inputs.length; ++n)
         if(Inputs[n].type == 'checkbox' && 
            Inputs[n].id.indexOf(chkBox,0) >= 0 && 
            Inputs[n].checked)
    
          return true;   
    

    Similarly you can check for the other checkbox too...

    0 讨论(0)
提交回复
热议问题