Making 'file' input element mandatory (required)

后端 未结 8 601
忘掉有多难
忘掉有多难 2020-12-31 00:11

I want to make (an HTML) \'file\' input element mandatory: something like


But it i

相关标签:
8条回答
  • 2020-12-31 00:37

    As of now in 2017, I am able to do this-

    <input type='file' required />
    

    and when you submit the form, it asks for file.

    0 讨论(0)
  • 2020-12-31 00:38

    Thanks to HTML5, it is as easy as this:

    <input type='file' required />
    

    Example:

    <form>
      <input type='file' required />
      <button type="submit"> Submit </button>
    </form>

    0 讨论(0)
提交回复
热议问题