标签:
———————————————————————————
<script type="text/javascript">
function chkform(){
var str = document.forms[0].mypic.value;
var name = str.substring(str.lastIndexOf(".")+1).toUpperCase(); //得到大写化的文件结尾
if (name!="JPG"&&name!="GIF"&&name!=‘PNG‘&&name!=‘BMP‘){
alert("格式不正确");
return false;
}else{
document.forms[0].submit();
}
}
</script>
————————————————————————
<body style="text-align:center">
<form action="" method="post" enctype="multipart/form-data" name="myform" onsubmit="chkform();return false;">
<label>
<input type="file" name="mypic" />
</label>
<label>
<input type="submit" name="Submit" value="提交"/>
</label>
</form>
</body>
————————————————————————————
标签:
原文地址:http://www.cnblogs.com/hanxuming/p/5920911.html