JSFiddle - React, Tailwind, and code Playground

by Barney Carroll

HTML

<input type="file" accept="image/*" onchange="validateFileFormat()" id="i" />

JavaScript

window.validateFileFormat = function(){
    alert( ( new RegExp( i.accept.replace( '*', '.\*' ) ) ).test( i.files[ 0 ].type ) );
}