asp如何判断文本框为空和如何使submit失效?

来源:百度知道 编辑:UC知道 时间:2024/05/26 11:44:46
a.asp有两个文本框,如果任何一个为空,那么submit就不可用;代码该怎么写啊?谢谢

已经测试过:
<form action="nextpage.asp" method="post" name="form1" onsubmit="javascript:return checkform()">
<input name="a" type="text" />
<input name="b" type="text" />
<input name="" type="submit" value="提交" />
</form>
<script language="javascript">
function checkform(){
if ((document.form1.a.value.length==0)||(document.form1.b.value.length==0)){
alert("两个都不能空!");
return false;
}
}
</script>