Advertisement
Guest User

Untitled

a guest
Nov 19th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.94 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>validering</title>
  4. <script>
  5. function Validate(){
  6.     var _validFileExtensions = ["xls","xla","xlb","xlc","xld","xlk","xll","xlm","xlt","xlv","xlsx","xlsm","xlsb","xltm","xlam"];
  7.     var input = document.getElementById("upload");
  8.     if(input.type == "file"){
  9.         var fileName = input.value;
  10.         var ext = fileName.substring(fileName.lastIndexOf('.') +1, fileName.length);
  11.         return _validFileExtensions.lastIndexOf(ext) >= 0;
  12.     }
  13.     return false;
  14. }
  15. (function(){
  16.     window.addEventListener('DOMContentLoaded',load, false);
  17. })();
  18.  
  19. function load(){
  20.     document.addFile.addEventListener('Submit', Validate, false);
  21. }
  22. </script>
  23. </head>
  24. <body>
  25. <form name="addFile" action="ctrl" method="POST" enctype="multipart/form-data" onSubmit="return Validate(this);">
  26.     <table>
  27.         <tr>
  28.             <td>File: </td>
  29.             <td><input id="upload" type="file" /></td>
  30.             <td><input type="submit" value="Add from file" /></td>
  31.         </tr>
  32.     </table>
  33. </form>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement