输入文件中的accept属性不起作用

sub*_*ash 6 html cross-browser html-input

您好我遇到了htnl中的浏览文件对话框控件标签.标签是

<input id="myfile" name="myfile" type="file" accept="application/pdf"/>
Run Code Online (Sandbox Code Playgroud)

但是accept属性似乎没有任何影响.使用internetexplorer 8浏览器

它与accept属性有什么关系吗?

小智 12

根据w3schools(http://www.w3schools.com/TAGS/att_input_accept.asp),任何主流浏览器都不能正确支持'accept'属性.文件浏览器对话框中的过滤器不起作用.

您可以在onsubmit事件表单上使用javascript验证来验证文件类型是否正确,否则返回false.

  • 我没有在页面中看到主要浏览器不支持它. (2认同)