输入元素的“接受”属性不起作用 [英] 'Accept' attribute of input element is not working

查看:91
本文介绍了输入元素的“接受”属性不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html中遇到了一个浏览文件对话框控制标记,标记为

I came across a browse file dialog-control tag in html and the tag was

<input id="myfile" name="myfile" type="file" accept="application/pdf"/>

,但是 accept属性似乎没有任何作用。我正在使用Internet Explorer 8。

but the 'accept' attribute doesn't seems to have any effect. I am using Internet Explorer 8.

推荐答案

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

according to the w3schools (http://www.w3schools.com/TAGS/att_input_accept.asp), the 'accept' attribute is not properly supported by any of the major browsers. The filter inside the file browser dialog will not work.

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

You could use a javascript validation on the form onsubmit event to verify if the file type is correct, returning false otherwise.

这篇关于输入元素的“接受”属性不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆