Javascript Form How to - Enable a button








Question

We would like to know how to enable a button.

Answer


<html>
<body>
<script>
    function function1() {<!-- w  w  w.  j  a  v a2s .c  om-->
        document.all.myButton.disabled = true;
    }
    function function2() {
        document.all.myButton.disabled = false;
    }
</script>
<input id="myButton" type="button" value="Disable" onClick="function1();">
<input type="button" value="Enable" onClick="function2();">
</body>
</html>

The code above is rendered as follows: