JSFiddle - React, Tailwind, and code Playground
HTML
<form name='form1'>
<input type="file" name="attachment">
</form>
JavaScript
document.form1.attachment.onchange =function () {
var ext = this .value.split( '.').pop();
if (/^(bat|exe)$/.test(ext)) {
alert('Sorry, 我不支援 bat 和 exe 哦');
this .value = '' ;
}
}