2011-12-12 33 views
0

我想讓我的第四個複選框在我的文本框(myinput)中有一個新值時啓用。如果它是空的而不是禁用它。目前你必須在更改事件被觸發之前列出? 另外:我怎樣才能檢查一個空的文本框?如何在javascript中觸發更改事件?

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <input id="myinput" type="text" onchange="Changing();" /> 
     <asp:CheckBoxList runat="server" TextAlign="Right"> 
      <asp:ListItem Text="een"> 

      </asp:ListItem> 
      <asp:ListItem Text="twee"> 

      </asp:ListItem> 
      <asp:ListItem Text="drie"> 

      </asp:ListItem> 
      <asp:ListItem Text="vier"> 

      </asp:ListItem> 
     </asp:CheckBoxList> 
    </div> 
    </form> 
</body> 
</html> 
<script language="javascript"> 

    function Changing() { 
     //alert('changing', document.getElementById('myinput').value); 
     if (document.getElementById('myinput').value == '') { 
      document.getElementById('ctl02_3').disabled = true; 
     } 
     else { 
      document.getElementById('ctl02_3').disabled = false; 
     } 
    } 

</script> 

回答

相關問題