<script type="text/javascript">
function chkform(form){
var bool=true;
if(form.title.value==""){
alert("你没有填姓名,此项为必填项");
form.email.focus();
bool=false;
}
else if(form.bh.value==""){
alert("你没填编号,此项为必填项");
form.address.focus();
bool=false;
}
if(bool)
form.submit();
}
</script>中间略
<form action='/e/search/index.php' method="post" target="_blank">
<input type="hidden" name="classid" id="13"value="13" />
<input type="hidden" name="andor" value="and" />
<input type="hidden" name="tempid" value="2">
<table width="320" border="0" cellspacing="0" cellpadding="0" style="border: #CCCCCC 1px solid; padding:10px;" align="center">
<tr>
<td>姓名:</td>
<td><input type="hidden" name="show[]" value="title">
<input type="hidden" name="hh[]" value="EQ">
<INPUT name=keyboard[] id="title" style="WIDTH:220px; HEIGHT: 18px" tabIndex=1 onkeydown="javascript:if(event.keyCode==13){return false;}" maxLength=20>
*</td>
</tr>
<tr>
<td>编号:</td>
<td><input type="hidden" name="show[]" value="bh">
<input type="hidden" name="hh[]" value="EQ">
<INPUT style="WIDTH:220px; HEIGHT: 18px" tabIndex=1 name=keyboard[] onkeydown="javascript:if(event.keyCode==13){return false;}" maxLength=20 id="bh">
*</td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="Submit22" type="submit" value="查询" onClick="chkform(form)" >
验证错误后表单继续提交,是什么问题呢?请各位指教。
function chkform(form){
var bool=true;
if(form.title.value==""){
alert("你没有填姓名,此项为必填项");
form.email.focus();
bool=false;
}
else if(form.bh.value==""){
alert("你没填编号,此项为必填项");
form.address.focus();
bool=false;
}
if(bool)
form.submit();
}
</script>中间略
<form action='/e/search/index.php' method="post" target="_blank">
<input type="hidden" name="classid" id="13"value="13" />
<input type="hidden" name="andor" value="and" />
<input type="hidden" name="tempid" value="2">
<table width="320" border="0" cellspacing="0" cellpadding="0" style="border: #CCCCCC 1px solid; padding:10px;" align="center">
<tr>
<td>姓名:</td>
<td><input type="hidden" name="show[]" value="title">
<input type="hidden" name="hh[]" value="EQ">
<INPUT name=keyboard[] id="title" style="WIDTH:220px; HEIGHT: 18px" tabIndex=1 onkeydown="javascript:if(event.keyCode==13){return false;}" maxLength=20>
*</td>
</tr>
<tr>
<td>编号:</td>
<td><input type="hidden" name="show[]" value="bh">
<input type="hidden" name="hh[]" value="EQ">
<INPUT style="WIDTH:220px; HEIGHT: 18px" tabIndex=1 name=keyboard[] onkeydown="javascript:if(event.keyCode==13){return false;}" maxLength=20 id="bh">
*</td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="Submit22" type="submit" value="查询" onClick="chkform(form)" >
验证错误后表单继续提交,是什么问题呢?请各位指教。
这里用了submit,js里又用了submit,虽然js里验证不通过无法提交,但input这里提交了,将input 里的
type属性改为button,就可以了