这是一段修改密码的页面代码<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>修改密码</title>
<LINK href="../style/adminCss.css" type=text/css rel=stylesheet>
<script type="text/javascript">
function check(){
var oldPassword=document.myform.oldpassword.value; //旧密码
var nowPassword=(String)session.getAttribute("loginPwd"); //这里是登陆时记录的密码
var password=document.myform.password.value; //新密码
var passwordTwo=document.myform.passwordtwo.value; //第二次输入新密码
if(oldPassword != nowPassword)
{
alert("旧密码不正确");
document.myform.oldPassword.focus();
return false;
}
if(oldPassword.length == 0)
{
alert("旧密码不能为空");
document.myform.guestname.focus();
return false;
}
if(password.length == 0)
{
alert("密码不能为空");
document.myform.password.focus();
return false;
}
if(passwordTwo.length == 0)
{
alert("确认密码不能为空");
document.myform.passwordtwo.focus();
return false;
}
if(password.length != 0 && passwordTwo != password)
{
alert("两次密码不一致");
return false;
}
return true;
}
</script></head>
<body onload="javascript:document.myform.oldpassword.focus()">
<form action="../do/doUpdatePassword.jsp" onsubmit="return check()" name="myform" method="post">
<TABLE class=tableborder cellSpacing=1 cellPadding=4 width="100%">
<TR>
<TD class=header colSpan=12>修改密码</TD>
</TR>
<TR>
<TD align="center" class=altbg1>旧 密 码:</TD>
<TD class="altbg2"><input type="password" name="oldpassword" style="width:200px" /></TD>
</TR>
<TR>
<TD align="center" class=altbg1>新 密 码:</TD>
<TD class="altbg2"><input type="password" name="password" style="width:200px" /></TD>
</TR>
<TR>
<TD align="center" class=altbg1>确认密码:</TD>
<TD class="altbg2"><input type="password" name="passwordtwo" style="width:200px" /></TD>
</TR>
<TR>
<TD class=altbg1></TD>
<TD class=altbg2 colSpan=11>
<INPUT type="submit" name="sub" value=" 提交 "> <INPUT type="reset" name="res" value=" 重置 ">
</TD>
</TR>
</TABLE>
</form></body>
</html>
可是执行后check()部分根本没作用,怎么回事?疯了要。
pageEncoding="GBK"%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>修改密码</title>
<LINK href="../style/adminCss.css" type=text/css rel=stylesheet>
<script type="text/javascript">
function check(){
var oldPassword=document.myform.oldpassword.value; //旧密码
var nowPassword=(String)session.getAttribute("loginPwd"); //这里是登陆时记录的密码
var password=document.myform.password.value; //新密码
var passwordTwo=document.myform.passwordtwo.value; //第二次输入新密码
if(oldPassword != nowPassword)
{
alert("旧密码不正确");
document.myform.oldPassword.focus();
return false;
}
if(oldPassword.length == 0)
{
alert("旧密码不能为空");
document.myform.guestname.focus();
return false;
}
if(password.length == 0)
{
alert("密码不能为空");
document.myform.password.focus();
return false;
}
if(passwordTwo.length == 0)
{
alert("确认密码不能为空");
document.myform.passwordtwo.focus();
return false;
}
if(password.length != 0 && passwordTwo != password)
{
alert("两次密码不一致");
return false;
}
return true;
}
</script></head>
<body onload="javascript:document.myform.oldpassword.focus()">
<form action="../do/doUpdatePassword.jsp" onsubmit="return check()" name="myform" method="post">
<TABLE class=tableborder cellSpacing=1 cellPadding=4 width="100%">
<TR>
<TD class=header colSpan=12>修改密码</TD>
</TR>
<TR>
<TD align="center" class=altbg1>旧 密 码:</TD>
<TD class="altbg2"><input type="password" name="oldpassword" style="width:200px" /></TD>
</TR>
<TR>
<TD align="center" class=altbg1>新 密 码:</TD>
<TD class="altbg2"><input type="password" name="password" style="width:200px" /></TD>
</TR>
<TR>
<TD align="center" class=altbg1>确认密码:</TD>
<TD class="altbg2"><input type="password" name="passwordtwo" style="width:200px" /></TD>
</TR>
<TR>
<TD class=altbg1></TD>
<TD class=altbg2 colSpan=11>
<INPUT type="submit" name="sub" value=" 提交 "> <INPUT type="reset" name="res" value=" 重置 ">
</TD>
</TR>
</TABLE>
</form></body>
</html>
可是执行后check()部分根本没作用,怎么回事?疯了要。
解决方案 »
- jsp中点击按钮怎么进入指定路径的文件夹?
- 关于pstmt.setTimestamp的问题
- 如何弹出消息框控制是否执行删除超链接?
- hibernate中多对一问题!很严重!
- 同样的编码,在不同的地方!!!求助.谢
- 在线等高手调错!!!!!!!!!!
- Jsp运行org.apache.jasper.JasperException: Unable to compile class for JSP:问题
- JSP中那句话相当于ASP中的<!--#include file="a.asp"-->?
- 怎么样让float型的变量保留2位小数?
- 一个jsp网页有表单form ,提交到一个servlet处理,如果防止用户多次重复按 "submit"提交键
- hql问题
- 手机网站用什么开发的呢?手机游戏程序是用什么开发的?请介绍下
var nowPassword= "<%=session.getAttribute("loginPwd").toString()%>"; //这里是登陆时记录的密码
不过 HTML 中含有用户的当前密码信息, 这样是不是威胁到用户的安全性
pageEncoding="GBK"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>修改密码</title>
<LINK href="../style/adminCss.css" type=text/css rel=stylesheet>
<script language="javascript" type="text/javascript">
function check(){
var oldPassword=document.myform.oldpassword.value; //旧密码
//把它放到页面的<input type="hidden">隐藏为FORM的一个属性
// var nowPassword=(String)session.getAttribute("loginPwd"); //这里是登陆时记录的密码
var password=document.myform.password.value; //新密码
var passwordTwo=document.myform.passwordtwo.value; //第二次输入新密码
// if(oldPassword != nowPassword)
// {
// alert("旧密码不正确");
//document.myform.oldPassword.focus();
// return false;
// }
if(oldPassword.length == 0)
{
alert("旧密码不能为空");
//guestname没这个属性
//document.myform.elements["guestname"].focus();
return false;
}
if(password.length == 0)
{
alert("密码不能为空");
document.myform.elements["password"].focus();
return false;
}
if(passwordTwo.length == 0)
{
alert("确认密码不能为空");
document.myform.elements["passwordtwo"].focus();
return false;
}
if(password.length != 0 && passwordTwo != password)
{
alert("两次密码不一致");
return false;
}
return true;
}
</script> </head>
<body onload="javascript:document.myform.oldpassword.focus()">
<form action="../do/doUpdatePassword.jsp" method="post" name="myform"
onsubmit="return check()" >
<TABLE class=tableborder cellSpacing=1 cellPadding=4 width="100%">
<TR>
<TD class=header colSpan=12>
修改密码
</TD>
</TR>
<TR>
<TD align="center" class=altbg1>
旧 密 码:
</TD>
<TD class="altbg2">
<input type="password" name="oldpassword" style="width:200px" />
</TD>
</TR>
<TR>
<TD align="center" class=altbg1>
新 密 码:
</TD>
<TD class="altbg2">
<input type="password" name="password" style="width:200px" />
</TD>
</TR>
<TR>
<TD align="center" class=altbg1>
确认密码:
</TD>
<TD class="altbg2">
<input type="password" name="passwordtwo" style="width:200px" />
</TD>
</TR>
<TR>
<TD class=altbg1></TD>
<TD class=altbg2 colSpan=11>
<INPUT type="submit" name="sub" value=" 提交 ">
<INPUT type="reset" name="res" value=" 重置 ">
</TD>
</TR>
</TABLE>
</form> </body>
</html>