C#前端頁面判斷控件

时间:2022-06-22 22:35:26

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;

}

     else {

flag = true;

}

}

}