Javascript Form How to - Remove focus from the FileUpload box








Question

We would like to know how to remove focus from the FileUpload box.

Answer


<!--from  w ww.j a  v  a  2 s .c  om-->
<html>
    <body>
    <script language="JavaScript">
    function showMessage(){
         document.form1.uploadbox.blur();
         document.form1.textbox.value = "File Submitted";
    }
    </script>
    <form name="form1">
    Enter Filename:
    <input type="file" name="uploadbox">
    <input type="button" value="Okay" onClick=showMessage()>
    <br><br>
    Confirmation:
    <input type="text" name="textbox">
    </form>
</body>
</html>

The code above is rendered as follows: