Javascript Form How to - Remove the focus from the RadioButton








Question

We would like to know how to remove the focus from the RadioButton.

Answer


<!--  w w w  .  j  a v a2  s .c  om-->
<html>
<body>
    <script language="JavaScript">
    function change(){
        document.form1.button1.blur();
        document.form1.text1.value="Focus removed from button";
    }
    </script>
    <form name="form1">
        <input type="radio" name=button1 CHECKED>Box 1
        <br>
        <input type="radio" name=button2>Box 2
        <br>
        <input type="button" value="Remove Focus" onClick='change()'>
        <br>
        <input type="text" name="text1" size=15>
    </form>
</body>
</html>

The code above is rendered as follows: