Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>validering</title>
- <script>
- function Validate(){
- var _validFileExtensions = ["xls","xla","xlb","xlc","xld","xlk","xll","xlm","xlt","xlv","xlsx","xlsm","xlsb","xltm","xlam"];
- var input = document.getElementById("upload");
- if(input.type == "file"){
- var fileName = input.value;
- var ext = fileName.substring(fileName.lastIndexOf('.') +1, fileName.length);
- return _validFileExtensions.lastIndexOf(ext) >= 0;
- }
- return false;
- }
- (function(){
- window.addEventListener('DOMContentLoaded',load, false);
- })();
- function load(){
- document.addFile.addEventListener('Submit', Validate, false);
- }
- </script>
- </head>
- <body>
- <form name="addFile" action="ctrl" method="POST" enctype="multipart/form-data" onSubmit="return Validate(this);">
- <table>
- <tr>
- <td>File: </td>
- <td><input id="upload" type="file" /></td>
- <td><input type="submit" value="Add from file" /></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement