Reputation: 11794
i am trying to make my 4th checkbox enabled as soon as there is a new value in my textbox (myinput). If it is empty than disable this. At the moment you have to tab out before the changing event is triggered? Also:how can I check for an empty textbox?
<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>
Upvotes: 0
Views: 231
Reputation: 48415
You can use the onkeyup event which will fire as the textbox value changes.
See here: http://www.w3schools.com/jsref/event_onkeyup.asp
Also the onkeydown and onkeypress events will yield similar results
Upvotes: 1