Making 'file' input element mandatory (required)

后端 未结 8 604
忘掉有多难
忘掉有多难 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:32

    var imgVal = $('[type=file]').val(); 
    

    Similar to Vivek's suggestion, but now you have a more generic selector of the input file and you don't rely on specific ID or class.

    See this demo.

提交回复
热议问题