Javascript Form How to - Handle focus lost event for File upload Input box








Question

We would like to know how to handle focus lost event for File upload Input box.

Answer


 <!--from w  w  w .jav a  2 s . c  om-->
<html>
<body>
    <script language="JavaScript">
    function inform(){
         document.form1.msg.value="File submitted and focus removed from FileUpload object";
    }
    </script>
    <form name="form1">
    Please choose a file to upload to the server.
    <br><br>
    <input type="file" onBlur= 'inform()'>
    <br><br>
    Click on the text box.
    <br><br>
    Message:
    <input type="text" name="msg" size="50">
    </form>
</body>
</html>

The code above is rendered as follows: