jsp中 不知道哪里错了,为什么无法验证输入框是否为空,代码如下:

<body>
<script type=text/javascript> //验证输入不能为空
funtion checkForm(){
if (document.getElementById("loginName").value==""){
alert("用户名不能为空!");
document.getElementById("loginName").focus();
return false;
}
if (document.getElementById("loginCode").value==""){
alert("密码不能为空!");
document.getElementById("loginCode").focus();
return false;
}
return true;

}
</script>

<form action="enter.jsp" method="post" onsubmit="return checkForm()">
<table>

<tr>
<td><h2>用户名:</h2></td><td><h3><input type="text" name="username" id="loginName" ></h3></td>
</tr>

<tr height="50">
<td></td><td><p id=tips></p></td>
</tr>

<tr>
<td><h2>密码:</h2></td><td><input type="text" name="password" id="loginCode" ></td>
</tr>

<tr>
<td><input type = "submit" value="登录" name="submit1"></td>
<td><input type="reset" value="重置" name="reset1"></td>
</tr>

</table>
</form>

<form>
<input type="checkbox" name="remembername" >
记住用户名
<b><a class="code" href="getPassword.jsp" target="_blank"> 忘记密码</a></b>
<b><a class="zhuce" href="register.jsp" target="_blank"> |免费注册</a></b>

</form>

</body>

第1个回答  推荐于2016-08-28
funtion checkForm() 的function写错了

alert("用户名不能为空!");的分号改成英文的就可以了本回答被提问者和网友采纳
相似回答