JSFiddle - React, Tailwind, and code Playground

HTML

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

JavaScript

window.validateFileFormat = function() {
  const valid = [...i.files].every(file => {
    if (!i.accept) {
      return true;
    }
    return i.accept.replace(/\s/g, '').split(',').filter(accept => {
      return new RegExp(accept.replace('*', '.\*')).test(file.type);
    }).length > 0;
  });
  alert('Valid: ' + valid);
}