<script type="text/javascript">
function check(){
if($("#type").combo("getValue")=="")
{
//alert("xx1");
$("#xx1").html("*");
return false;
}
if($("#type2").combo("getValue")=="")
{
//alert("xx2");
$("#xx2").html("*");
return false;
}
//alert(" 33"+inspector);
if(inspector=="")
{
alert("dd");
$("#xx4").html("*");
return false;
}
if($("#type3").combo("getValue")=="")
{
$("#xx3").html("*");
return false;
}
}
</script>
<form οnsubmit="return check();">
<input type=submit value=确定>
</form>
或者
<form ..>
<input type=submit value=确定 onClick="return check();">
</form>
注意:onClick中返回值return check() 中check()的返回值true、false和没有返回值是不一样的。
表单提交时,执行check会弹出提示,然后如果return true的话,表单会提交,
return false表单则不会提交,
如果仅仅只有return 则表单提交,但要报错。
若type=button,不是提交按钮,函数也不是在表单提交时执行的验证,
所以return什么都不会有作用的。