jsp判断两次密码是否一致,怎么打?
我已经把注册界面打出来了,但判断两次密码是不是一致,怎么写代码?我的代码如下:<%@pagelanguage="java"contentType="text/html;c...
我已经把注册界面打出来了,但判断两次密码是不是一致,怎么写代码?我的代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎注册</title>
</head>
<body>
<div align="center">请输入注册信息<form name="form1" method="post"action="reginfo.jsp">
<table border="0"align="center">
<tr>
<td>请输入您的姓名:</td>
<td><input type="text"name="name"></td>
</tr>
<tr>
<td height="12">请输入您的密码:</td>
<td height="12"><input type="password"name="password"></td>
</tr>
<tr>
<td height="12">请再次输入您的密码:</td>
<td height="12"><input type="password"name="passwordConfirm"></td>
</tr>
<tr>
<td>请输入您的昵称:</td>
<td><input type="text"name="nickname"></td>
</tr>
<tr>
<td>
<div align="right">
<input type="submit"name="Submit"value="提交信息">
</div>
</td>
<td>
<input type="button"name="btn"value="返回上一页"onclick="history.go(-1)">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
两次密码要一致的判断怎么写?写在哪?请说明详细些,菜鸟求教、、、 展开
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎注册</title>
</head>
<body>
<div align="center">请输入注册信息<form name="form1" method="post"action="reginfo.jsp">
<table border="0"align="center">
<tr>
<td>请输入您的姓名:</td>
<td><input type="text"name="name"></td>
</tr>
<tr>
<td height="12">请输入您的密码:</td>
<td height="12"><input type="password"name="password"></td>
</tr>
<tr>
<td height="12">请再次输入您的密码:</td>
<td height="12"><input type="password"name="passwordConfirm"></td>
</tr>
<tr>
<td>请输入您的昵称:</td>
<td><input type="text"name="nickname"></td>
</tr>
<tr>
<td>
<div align="right">
<input type="submit"name="Submit"value="提交信息">
</div>
</td>
<td>
<input type="button"name="btn"value="返回上一页"onclick="history.go(-1)">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
两次密码要一致的判断怎么写?写在哪?请说明详细些,菜鸟求教、、、 展开
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎注册</title>
</head>
<body>
<div align="center">请输入注册信息<form name="form1" method="post"action="reginfo.jsp">
<table border="0"align="center">
<tr>
<td>请输入您的姓名:</td>
<td><input type="text"name="name"></td>
</tr>
<tr>
<td height="12">请输入您的密码:</td>
<td height="12"><input id="password" type="password"name="password"></td>
</tr>
<tr>
<td height="12">请再次输入您的密码:</td>
<td height="12"><input id="passwordConfirm" type="password" name="passwordConfirm"></td>
</tr>
<tr>
<td>请输入您的昵称:</td>
<td><input type="text"name="nickname"></td>
</tr>
<tr>
<td>
<div align="right">
<input id="sub" type="button" name="Submit" value="提交信息" >
</div>
</td>
<td>
<input type="button"name="btn"value="返回上一页"onclick="history.go(-1)">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<script>
(function(){
var sub = document.getElementById("sub");
//初始化移入移出事件
if(sub.addEventListener){
sub.addEventListener("click", test);
}else if(sub.attachEvent){
sub.attachEvent("onClick", test);
}
})();
function test(){
var password = document.getElementById("password");
var passwordConfirm = document.getElementById("passwordConfirm");
if(password.value != passwordConfirm.value)
alert("对不起,您2次输入的密码不一致");
else
document.forms[0].submit();
}
</script>
更多追问追答
追问
不对,直接就是输出到信息表了,没有判断
追答
html 代码有变化仔细查看:
建议:写代码一定要先从自身找问题一定要细心
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询