js如果禁用掉表单提交

网站基本信息如下<input type="text" onblur="test()"/><input type="submit" value="提交"/>----------------------------------------------我的效果如下当我文本框不输入任何值的话,表单就提交不上。请问要怎么写onblur="test()"

第1个回答  2013-10-25
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function check(f)
{
if(f.test.value=="")
{
alert('值不能为空!');
return false;
}
}
</script>
</head><body>
<form id="form1" name="form1" method="post" action="" onsubmit="return check(this)">
<input type="text" name="test" />
<input type="submit" name="Sub" value="提交" />
</form>
</body>
</html>
第2个回答  2013-10-25
function sub(){if(document.getElementByName("text1").value="")return false;elsedocument.form1.submit();}<form name="form1"><input type="text" name="text1" /><input type="button" value="提交" onclick="sub()"/></form>大概这样了