How do I make the widget required in a form?

The widget uses an input field of type hidden. According to the HTML specification, the required attribute doesn’t work with this type of inputs. However, you can change the type to text and hide the input with CSS. Thus you’ll be able to set HTML validation and error messages. For example,

<input type="text" role="uploadcare-uploader" name="file-upload" style="display:none" required />