0

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>

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.