技術(shù)_網(wǎng)頁(yè) 2007-07-19 13:06:26 閱讀197 評論0 字號:大中小 訂閱
http://www.mltang.com/article/6abb4e41-844a-4e7b-aa2d-90ce716fc241.html
問(wèn):
怎么過(guò)濾文件后綴<input type="file"> 讓他只顯示*.jpg和*.gif
______________________________________________________________________________________________
答1:
you cannot do that in all major browsers
______________________________________________________________________________________________
答2:
<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>
______________________________________________________________________________________________
答3:
<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')};">
______________________________________________________________________________________________
答4:
<input id=t type="file">
<script>
t.focus()
new ActiveXObject("wscript.shell").sendKeys(".gif")
</script>
______________________________________________________________________________________________
答5:
<input id=t type="file">
<script>
t.focus()
new ActiveXObject("wscript.shell").sendKeys(".gif")
</script>
聯(lián)系客服