<script> | |
function CheckForm(){ | |
//产品图片 | |
var tmp = document.getElementById('postfile').value; | |
var obj = document.getElementById('postfile'); | |
//alert(tmp); | |
//alert(obj); | |
if(tmp!=''){ | |
tmp = tmp.toLowerCase(); | |
var patten = /(.jpg|.png|.gif)$/; | |
if(tmp.search(patten)<= -1){ | |
alert('只允许上传 jpeg/gif/png 格式的文件'); | |
return false; | |
} | |
} | |
return true; | |
} | |
</script> | |
<form method="post" onsubmit="javascript:return CheckForm();"> | |
<input type=file name=postfile id="postfile"> | |
<input type=submit value="upload"> | |
</form> | |