File input onclick prevent change if user cancels confirm() - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

File input onclick prevent change if user cancels confirm()

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function check() {/*from w w w.  ja v  a  2s .c o m*/
    return confirm('Okay or cancel, if you cancel no dialog window will be displayed.');
}

      </script> 
   </head> 
   <body> 
      <input name="post_file" onclick="return check()" type="file" value="">  
   </body>
</html>

Related Tutorials