为什么我输入是空白的话,浏览器能提出"标题不能为空!",但当我的字符超过4个时,什么不能提出错误来?
<html>
<head>
<script language="javascript">
function ChkFields()
{
if(document.form1.tx1.value=='')
{
window.alert("标题不能为空!")
form1.tx1.focus()
return false
}
if(document.form1.tx1.value.length>4)
{
window.aletr ("标题超长!")
form1.tx1.focus()
return false
}
return true;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>发表新日志</title>
</head>
<body>
<form name="form1" method="post" action="" onsubmit= "return ChkFields()">
<div align="center">
<tr>
<td width="582" height="40"> <div align="center">文章标题:
<input name="tx1" type="text" size="50">
</div></td>
</tr>
<div align="center">
<input type="submit" name="Submit" value="提交"><input type="reset" value="全部重写" name="B2"></div></td>
</div>
</form>
</body>
</html>