<form action="index.php" method="post" enctype="multipart/form-data" onsubmit="return check_form(this)">
<input type="file" id="file" />
<input type="submit" value="确定" />
</form><script type="text/javascript">
function check_form(obj){
var file = document.getElementById('file');
var value = file.value;
var type = value.substr(a.lastIndexOf('.') + 1);
if(type != 'zip'){
alert('不是zip文件');
return false;
}
return true;
}
</script>
<input type="file" id="file" />
<input type="submit" value="确定" />
</form>
<script type="text/javascript">
function check_form(){
var file = document.getElementById('file').value;
var reg=/\.zip$/i;
if(!reg.test(file)){
alert("注:请上传zip压缩包!");
return false;
}
}
</script>