如何在客户端判断一个下拉框选择是否为空.........
<asp:DropDownList id="dropdownlist" runat="server">
  <asp:ListItem value="0" Text=""/>
  <asp:ListItem value="1" Text="A"/>
  <asp:ListItem value="2" Text="B"/>
  <asp:ListItem value="3" Text="C"/>
</asp:DropDownList>
我的问题是如何在客户端判断....
我着么写的。
<script>
function check()
  if(document.Form1.dropdownlist.SelectedItem.value=="0")
    {
      return false;
    }
</script>
不起什么做用不知道该怎么写......

解决方案 »

  1.   

    在<asp:DropDownList id="dropdownlist" runat="server">中再加上onChange="check(this.value)"
    试试看,没测试过的。
      

  2.   

    试试这样写
    <script>
    function check()
      if(document.Form1.ddlSectors.options[document.Form1.ddlSectors.selectedIndex].value=="0")
        {
          return false;
        }
    </script>
      

  3.   

    试试这样写
    <script>
    function check()
      if(document.Form1.dropdownlist.options[document.Form1.dropdownlist.selectedIndex].value=="0")
        {
          return false;
        }
    </script>
      

  4.   

    <script language="javascript">
    var obj = document.getElementById("DropDownList1");
    if (obj.options.length == 0)
    {
        //空
    }
    </script>
      

  5.   

    <script language="javascript" event="onchange" for="dropdownlist">  if(document.all.dropdownlist.value=="0")
        {
          alert("选的是0");
          return false;
        }
        else
        {
              alert("选的不是0");
        }</script>//注意在客户端的写法:document.all.dropdownlist.value
      

  6.   

    在服务器端
    this.DropDownList1.Attributes.Add("onchange","return check()");