Javascript Form How to - Remove focus from the submit button








Question

We would like to know how to remove focus from the submit button.

Answer


<!--from w  w  w.  j av a2 s  . co  m-->
<html>
<head>
    <script language="JavaScript">
    function removeFocus(){
      document.myForm.mySubmit.blur();
    }
    </script>
</head>
<body>
    <form name="myForm">
      <input type=TEXT value="Hello, World!" name="myText">
      <input type=SUBMIT value="Click to Remove Focus" name="mySubmit" onClick="removeFocus()">
    </form>
</body>
</html>

The code above is rendered as follows: