JSFiddle - React, Tailwind, and code Playground

by mrk1989

HTML

<input type='file' id ="browse" name ="browse"/>

JavaScript

var file = document.getElementById('browse');
         file.onchange = function(e){
            var ext = this.value.match(/\.([^\.]+)$/)[1];
            switch(ext)
            {
                case 'xls':
                    alert('allowed');
                    break;
                default:
                    alert('not allowed');
                    this.value='';
            }
    };