<div>
  <p>
    <code>data-file-types="mp3"</code><br />
    <input
      name="greeting_mp3"
      type="hidden"
      role="uploadcare-uploader"
      data-file-types="mp3"
      data-input-accept-types="audio/mpeg"
    />
  </p>
</div>
body {
  margin: 16px;
}

p {
  margin: 8px 0;
}

code {
  font-family: monospace;
}
function fileTypeLimit(types) {
  types = types.split(' ')

  return function(fileInfo) {
    if (fileInfo.name === null) {
      return
    }
    var extension = fileInfo.name.split('.').pop()

    if (types.indexOf(extension) == -1) {
      throw new Error('fileType')
    }
  }
}

$(function() {
  $('[role=uploadcare-uploader][data-file-types]').each(function() {
    var input = $(this)
    var widget = uploadcare.Widget(input)

    widget.validators.push(fileTypeLimit(input.data('file-types')))
  })
})

UPLOADCARE_LOCALE_TRANSLATIONS = {
  // messages for widget
  errors: {fileType: 'This type of files is not allowed.'},
  // messages for dialog’s error page
  dialog: {
    tabs: {
      preview: {
        error: {
          fileType: {
            title: 'Title.',
            text: 'Text.',
            back: 'Back',
          },
        },
      },
    },
  },
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js
  2. https://ucarecdn.com/libs/widget/3.x/uploadcare.min.js