JSFiddle - React, Tailwind, and code Playground

by Amin Kodaganur

HTML

<form id="file_upload" action="">
    <input type="file" id='file' name="datafile">
    
        <input type="submit" value="submit"/>
</form>

JavaScript

$('#file').change(function(e) {
    
	  var file = $(this).val();
	  var ext = file.split('.').pop();
	  alert(ext);
      
      if(ext=='jpg'){
      	alert('correct file');
      }else{
      	alert('wrong file');
        return false;
      }
});