Invalid location of tag (script)应该怎么改 新手刚接触 好多不明白
<%@ page contentType ="text/html pageEncoding=gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script language="javascript" >
function init(){
alert("${info}");
}
<c:if test="${!empty info}">
window.onload=init;
</c:if>
function isValidate(form)
{
//得到用户输入信息
username = form.username.value;
userpass = form.userpass.value;
//判断用户名长度
if(!minLength(username,6))
{
alert("用户名长度小于6位!");
form.username.focus();
return false;
}
if(!maxLength(username,8))
{
alert("用户名长度大于8位!");
form.username.focus();
return false;
}
//判断口令长度
if(!minLength(userpass,6))
{
alert("口令长度小于6位!");
form.userpass.focus();
return false;
}
if(!maxLength(userpass,8))
{
alert("口令长度大于8位!");
form.userpass.focus();
return false;
}
return true;
}
//验证是否满足最小长度
function minLength(str,length)
{
if(str.length >= length)
return true;
else
return false;
}
//验证是否满足最大长度
function maxLength(str,length)
{
if(str.length <=length)
return true;
else
retrun false;
}
</script>
<html >
<head>
<title>用户登录</title>
</head>
<body ><div align="center">
<h2>用户登录</h2><br>
<form name ="form1" action = "LoginServlet" method = "post"
onsubmit = “return isValidate(form1)”>
用户名:<input type ="text" name = "username"><br><br>
密 码:<input type ="password" name = "userpass"><br><br>
<input type = "reset" value = "重置">
<input type = "submit" value = "提交"><br>
</form>
<font size="2"><a href="addUser.jsp">(新用户注册)</a></font>
</div></body>
</html>
[解决办法]
onsubmit = “return isValidate(form1)”
alert("用户名长度大于8位!");
retrun false;
都是中文符号或者拼写错误,自己找一下吧