帮我看看,这段js验证代码,什么地方,出错了,谢谢了.

来源:百度知道 编辑:UC知道 时间:2024/05/18 16:15:01
<form name="zhuce" onSubmit="return checkform();" action="">
帐号<input type="text" name="T1" size="20"><br>
<input type="submit" value="提交" name="B1">
</form>
<script language="javascript">
function checkform()
{
if (this.T1.value==''){alert('用户名不能为空!');return false;}
}
</script>

this.T1.value
改成
this.zhuce.T1.value

<form name="zhuce" onSubmit="return checkform();" action="">
帐号<input type="text" name="T1" size="20"><br>
<input type="submit" value="提交" name="B1">
</form>
<script language="javascript">
function checkform()
{
if (document.getElementById('T1').value==''){alert('用户名不能为空!');return false;}
}
</script>