求助submit提交不了表单,点击submit按钮,死活没用,代码如下,望高手指导
<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><!DOCTYPEHTMLPUBLIC"-...
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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("请输入用户名!");
return false;
}
if(password.value.length<6 || password.value.length>10)
{
alert("密码长度应在6-10之间!");
return false;
}
if(repassword.value.length<6 || repassword.value.length>10)
{
alert("密码长度应在6-10之间!");
return false;
}
if(password.value != repassword.value)
{
alert("两次输入的密码不一致!");
return false;
}
return false;
}
</script>
</head>
<body>
<form onsubmit="return validate();" action="someServlet">
username:<input type="text" name="username" id="username1"><br>
password:<input type ="password" name="password" id="password1"><br>
re-password:<input type ="password" name="repassword" id="repassword1"><br>
<input type = "submit" name="submit1" value="submit">
</form>
</body>
</html> 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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("请输入用户名!");
return false;
}
if(password.value.length<6 || password.value.length>10)
{
alert("密码长度应在6-10之间!");
return false;
}
if(repassword.value.length<6 || repassword.value.length>10)
{
alert("密码长度应在6-10之间!");
return false;
}
if(password.value != repassword.value)
{
alert("两次输入的密码不一致!");
return false;
}
return false;
}
</script>
</head>
<body>
<form onsubmit="return validate();" action="someServlet">
username:<input type="text" name="username" id="username1"><br>
password:<input type ="password" name="password" id="password1"><br>
re-password:<input type ="password" name="repassword" id="repassword1"><br>
<input type = "submit" name="submit1" value="submit">
</form>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询