C#前端頁面判斷控件

时间:2022-03-02 05:34:43

var chbClass = document.getElementById("<%=DDL_CheckboxUserClass1.ClientID %>" + "_chbClass");

if (chbClass != undefined)

{      

  var inputs = chbClass.getElementsByTagName("input");  

var count = 0;

for (var i = 0; i < inputs.length; i++)

  {

     if (inputs[i].checked == true)

      {                        

         count++;

      }

  }    

  if (count == 0)

  {

alert("文件小類不能選擇為空!");

flag = false;  

return flag;

}

  else

  {    

flag = true;        

}

if (add)

      {

if (count != 1)

       {   

alert("新增時,,文件小類不能選擇多個!");   

flag = false;

return flag;

}