首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jsp 检测密码两次输入是否相同解决办法

2012-03-21 
jsp 检测密码两次输入是否相同我的文件不能判断,点击提交后不判断直接修改数据库文件是一个修改密码的操作

jsp 检测密码两次输入是否相同
我的文件不能判断,点击提交后不判断直接修改数据库
文件是一个修改密码的操作
大家帮忙看下输入不合法为什么没有弹窗
<%@   page   pageEncoding= "GBK "%>
<%@   page   import= "java.sql.* "   %>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 修改密码   </title>
<script   language= "JavaScript ">
function   OnFocus(){
document.change.user.focus();
}
function   isValid(){
conForm=true;
if(document.change.user.value.length==0){
conForm=false;
window.alert( '必须输入帐号才能完成登陆! ');
document.change.elements(0).focus();

}
else   if(document.change.pwd1.value.length==0){
conForm=false;
window.alert( '必须输入原密码 ');
doucument.change.elements(1).focus();

}
else   if(document.change.pwd2.value.length==0){
conForm=false;
window.alert( '必须输入现在的密码 ');
doucument.change.elements(2).focus();

}
else   if(document.change.pw2.value!=document.change.pw3.value){
conForm=false;
pw3.value= " ";
window.alert( '两次输入的密码不一样 ');
doucument.change.elements(3).focus();

}
return   conForm;  

}
</script>
</head>
           

<body     onLoad= "OnFocus() "   bgcolor= "#0099FF "   background= "tj1.jpg ">

<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<form   name= "change "   method= "post "   action= "changekeyword.jsp "   onSubmit= "return   isValid() ">
    <p   align= "center "> 帐&nbsp;&nbsp;&nbsp;&nbsp;户:  
        <input   type= "text "   name= "user ">
</p>
    <p   align= "center "> 原始密码:   <input   type= "password "   name= "pwd1 ">
    </p>
      <p   align= "center "> 密&nbsp;&nbsp;&nbsp;&nbsp;码:  
      <input   type= "password "   name= "pwd2 ">
      </p>
      <p   align= "center "> 确认密码:  
      <input   type= "password "   name= "pwd3 ">
      </p>
      <p   align= "center "> <input   type= "submit "   name= "ok "   value= "提交 "   >
      &nbsp;&nbsp;&nbsp;
      <input   type= "reset "   name= "reset "   value= "重置 ">
      </p>
</form>
</body>
</html>


[解决办法]
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 修改密码 </title>
<script language= "JavaScript ">

function isValid(){
conForm=true;
if(document.change.user.value.length==0){


conForm=false;
window.alert( '必须输入帐号才能完成登陆! ');
document.change.elements(0).focus();
return false;

}
else if(document.change.pwd1.value.length==0){
conForm=false;
window.alert( '必须输入原密码 ');
doucument.change.elements(1).focus();
return false;

}
else if(document.change.pwd2.value.length==0){

window.alert( '必须输入现在的密码 ');
doucument.change.elements(2).focus();
return false;

}
else if(document.change.pwd2.value != document.change.pwd3.value){
document.change.pwd3.value= " ";
window.alert( '两次输入的密码不一样 ');
doucument.change.elements(3).focus();
return false;
}
return true;
}
</script>
</head>


<body onLoad= "document.change.user.focus(); " bgcolor= "#0099FF " background= "tj1.jpg ">

<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<form name= "change " method= "post " id= "ppp " action= "changekeyword.jsp ">
<p align= "center "> 帐&nbsp;&nbsp;&nbsp;&nbsp;户:
<input type= "text " name= "user ">
</p>
<p align= "center "> 原始密码: <input type= "password " name= "pwd1 ">
</p>
<p align= "center "> 密&nbsp;&nbsp;&nbsp;&nbsp;码:
<input type= "password " name= "pwd2 ">
</p>
<p align= "center "> 确认密码:
<input type= "password " name= "pwd3 ">
</p>
<p align= "center "> <input type= "button " name= "ok " onClick= "if(isValid()) document.getElementById( 'ppp ').submit(); " value= "提交 " >
&nbsp;&nbsp;&nbsp;
<input type= "reset " name= "reset " value= "重置 ">
</p>
</form>
</body>
</html>

热点排行
Bad Request.