<html:form>标签onsubmit属性提交到js有执行,虽然返回了false但还是直接跳到action,怎么回事?
javascript:<scripttype="text/javascript">functiondoSubmitPolicy(){varwarning=document...
javascript:
<script type="text/javascript">
function doSubmitPolicy(){
var warning = document.getElementById('warning');
warning.innerHTML='';
var cipolicyno = document.getElementById('cipolicyno');
var capolicyno = document.getElementById('capolicyno');
if(cipolicyno.value.length == 0){
waring.innerHTML='<font color=red>请输入交强险保单号</font>';
return false;
}
if(capolicyno.value.length == 0){
waring.innerHTML='<font color=red>请输入商业险保单号</font>';
return false;
}
return true;
}
</script>
jsp代码:
</td>
<html:form action="/showPolicy" onsubmit="return doSubmitPolicy();">
<td>
交强险保单号:
</td>
<td>
<html:text styleId="cipolicyno" property="ciPolicyNo" size="25" maxlength="25"/>
</td>
<td>
商业险保单号:
</td>
<td>
<html:text styleId="capolicyno" property="caPolicyNo" size="25" maxlength="25"/>
</td>
<td>
</td>
<td>
<html:submit property="submit" value="查询"/>
</td>
</html:form> 展开
<script type="text/javascript">
function doSubmitPolicy(){
var warning = document.getElementById('warning');
warning.innerHTML='';
var cipolicyno = document.getElementById('cipolicyno');
var capolicyno = document.getElementById('capolicyno');
if(cipolicyno.value.length == 0){
waring.innerHTML='<font color=red>请输入交强险保单号</font>';
return false;
}
if(capolicyno.value.length == 0){
waring.innerHTML='<font color=red>请输入商业险保单号</font>';
return false;
}
return true;
}
</script>
jsp代码:
</td>
<html:form action="/showPolicy" onsubmit="return doSubmitPolicy();">
<td>
交强险保单号:
</td>
<td>
<html:text styleId="cipolicyno" property="ciPolicyNo" size="25" maxlength="25"/>
</td>
<td>
商业险保单号:
</td>
<td>
<html:text styleId="capolicyno" property="caPolicyNo" size="25" maxlength="25"/>
</td>
<td>
</td>
<td>
<html:submit property="submit" value="查询"/>
</td>
</html:form> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询