file tag validation
HTML
<input type="file" placeholder="Video file" class="dupFile" id="gl_video_file">
JavaScript
$('body').on('change', '#gl_video_file', function(e) {
var glVideoFiles = event.target.files;
glVideoFileSplit = glVideoFiles[0].name.split(".");
glVideoFileFormat = glVideoFileSplit[1];
glVideoFileName = glVideoFileSplit[0].split(' ').join('_')
//alert ("File name : "+glVideoFileName)
if (!glVideoFileName.match(/^[a-z0-9_-]+(\.mp4)$/i)) {
alert('First check : Bad file name format.');
}
if (!($('#gl_video_file').val()).match(/^[a-z0-9_-]+(\.jpg)$/i)) {
alert('Second check : Bad file name format.');
}
if (this.files[0].size > maxFileSize) {
alert("File size is too big.");
}
});