html - Making 'file' input element mandatory (required) -


i want make (an html) 'file' input element mandatory: like

<input type='file' required = 'required' .../> 

but not working.

i saw ww3 manual states 'required' attribute new html 5. not using html 5 in project working doesn't support new feature.

any idea?

you can using jquery this:-

<script type="text/javascript"> $(document).ready(function() {     $('#upload').bind("click",function()      {          var imgval = $('#uploadfile').val();          if(imgval=='')          {              alert("empty input file");              return false;          }        });  }); </script>   <input type="file" name="image" id="uploadfile" size="30" />  <input type="submit" name="upload" id="upload"  class="send_upload" value="upload" /> 

Comments