怎么过滤文件后缀 让他只显示*.jpg和*.gif

floydyxc 2002-07-08 09:32:49
怎么过滤文件后缀<input type="file"> 让他只显示*.jpg和*.gif
...全文
459 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
floydyxc 2002-07-11
  • 打赏
  • 举报
回复
多谢
希默软件 2002-07-09
  • 打赏
  • 举报
回复
<input type=file id=myImg>
<input type=button value=check onclick="var aa=myImg.value.split('.');if(aa[aa.length-1]=='gif'||aa[aa.length-1]=='jpg'){alert('*.jpg or *.gif')}else{alert('Not *.jpg or *.gif')};">
qiushuiwuhen 2002-07-09
  • 打赏
  • 举报
回复
<input id=t type="file">
<script>
t.focus()
new ActiveXObject("wscript.shell").sendKeys(".gif")
</script>
qiushuiwuhen 2002-07-09
  • 打赏
  • 举报
回复
<input id=t type="file">
<script>
t.focus()
new ActiveXObject("wscript.shell").sendKeys(".gif")
</script>
lanbor 2002-07-08
  • 打赏
  • 举报
回复
<html>
<head>
<script language=javascript>
function checkImage(sId)
{
if(( document.all[sId].value.indexOf(".gif") == -1) && (document.all[sId].value.indexOf(".jpg") == -1)) {
alert("请选择gif或jpg的图象文件");
event.returnValue = false;
}
}
</script>
</head>
<body>
<form action='dddd.asp' onsubmit="checkImage('myImg')">
<input type=file id=myImg>
<input type=submit name=submit value=submit>
</form>
</body>
</html>
saucer 2002-07-08
  • 打赏
  • 举报
回复
you cannot do that in all major browsers

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧