日期:2014-05-16  浏览次数:20513 次

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(){