//验证上传的格式
function clickFileName(upload_field) {
var filename = upload_field.value;
var newFileName = filename.split('.');
newFileName = newFileName[newFileName.length-1];
if (/^(xls|xlsx|XLS|XLSX)$/.test(newFileName)==false) {
alert("上传的文件格式只能为Excel格式(2003或者2007版本的)");
upload_field.form.reset();
return false;
}
}
//提交前验证提交的数据
function verityFile(){
if($("#userfile").val()==null||$("#userfile").val()==''||$("#userfile").val()=="undefined"){
alert("请选择文件导入!");
return false;
}
var lockFlag = isLock();
if (lockFlag){
alert('已有数据正在导入,请稍后再试!');
return false;
}
return true;
}
//判断是否有数据正在导入
function isLock(){
var isLock = false;
$.ajax({
type:"post",
async:false,
url:"<%=basePath%>propertyPayment_Payment_importPropertyInfoLock.do",
success:function(data,status){
if(status && data == '0'){
isLock = true;
}
}
});
return isLock;
}
</script>
<table width="610px" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="100%">
<form id="uploadForm" name="uploadForm" method="post" enctype="multipart/form-data" action="***_Payment_importPropertyInfo.do" οnsubmit="return verityFile()">
<table id="personal_table" border="0" cellpadding="2" cellspacing="1" width="100%" align="center" style="">
<tr style=" COLOR: #000;" >
<td width="10%">文件上传:</td>
<td width="63%">
<input type="file" id="userfile" name="userfile" οnchange="clickFileName(this)" >
</td>
</tr>
<tr >
<td nowrap="nowrap" ></td>
<td >
<input class="input_img" type="submit" value="提交"/>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>