在MyEclipse里面写JavaScript好像有点问题
本帖最后由 cumt_TTR 于 2011-12-08 19:21:57 编辑
MyEclipse10.0+TomCat7.0
==============================
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyLogin.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function validate()
{
var username=document.getElementById("username1");
var password=document.getElementById("password1");
var repassword=document.getElementById("repassword1");
if(username.value.length==0)
{
alert("username can't be empty!");
return false;
}
if(password.value.length<6 || password.value.length>10)
{
alert("password's length shouled between 6 to 10!");
return false;
}
if(repassword.value.length<6 || repassword.value.length>10)
{
alert("password's length shouled between 6 to 10!");
return false;
}
if(password.value!=null && repassword.value!=null && password!=repassword)
{
alert("password wrong!");
return false;
}
return true;
}
</script>
</head>
<body>
<form onsubmit=
"return validate()" action="MyLoginServlet">
<!--这里老是红线,提示:Cannot return from outside a function or method-->
username:<input type="text" name="username" id="username1"><br/>
password:<input type="password" name="password" id="password1"><br/>
repassword:<input type="password" name="password" id="repassword1"><br/>
<input type="submit" value="submit">