Oo缘来是你oO


posts - 120,comments - 125,trackbacks - 0
                                        简单的密码验证控件

                                                     马嘉楠   2006-12-07

最近一直在忙,不过忙得很充实,学到了很多东西,准备一点一点整理.
这个密码验证很简单,作为一个独立的控件,可以拿来直接用^+^


pwd.html


<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
< HTML >
< HEAD >
< TITLE > 密码修改 </ TITLE >
</ HEAD >
< script  language ="javascript" >
// 密码修改
function  CheckUpdatePwd(text){
    
if ( ! confirm( " 确认修改密码? "
))
        
return
 ;
    
var  newpwd  =  window.showModalDialog('confirmpwd.htm',  "" " dialogWidth: 280px; dialogHeight: 150px; help: no; status: no "
);
    
if (newpwd == ""   ||  newpwd == null
) {
        alert(
" 密码没有修改! "
);
        
return   true
;
    }
else
 {;
        text.value 
=
 newpwd;
        
return
;
    }
}
</ script >


< BODY >
< table  id ="pwdTable"  width ="100%"  height ="100%"  border ="0"  cellspacing ="2"  cellpadding ="0" >  
< tr >

< td  align ="right"  width ="75" > 客户密码: </ td >  
< td >   < input  type ="password"  datafld ="cust_pwd"  name ="cust_pwd"  style ="border:1px solid #CCCCCC; font-size:12px; background-color:#FFFFFF; width:135px"  onFocus ="CheckUpdatePwd(this)"  maxlength ="6" >
 
< font  color ="#FF0000" > </ font >   </ td >

</ tr >
</ table >
</ BODY >
</ HTML >


confirmpwd.htm

< html >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
< link  href ="../../css/all_import.css"  rel =stylesheet >
< title > 密码修改 </ title >
< script  language ="JavaScript"  type ="text/JavaScript" >
function  modifyPwd() {
    
var  newPwd         =  document.all( " newPwd "
).value;
    
var  confirmPwd     =  document.all( " confirmPwd "
).value;

    
if (newPwd.length  ==   0
) {
        alert(
" 请输入新密码! "
);
        
return
;
    } 
else   if (newPwd.length  !=
 confirmPwd.length){
        alert(
" 密码长度不一致,请重新输入! "
);
        resetConfirmPwd();
        
return
;
    } 
else   if (newPwd  !=
 confirmPwd) {
        alert(
" 两次输入的密码不一致,请重新输入! "
);
        resetConfirmPwd();
        
return
;
    } 
else
{
        alert(
" 密码修改成功! "
)
        window.returnValue 
=
 newPwd;
            window.close();
    }
}

function
 resetConfirmPwd(){
    document.all.newPwd.value 
=   ""
;
    document.all.confirmPwd.value 
=   ""
;
}
</ script >

</ head >
< body  bgcolor ="#f0f0f0" >  
< table  width ="100%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
 
  
< tr >
 
    
< td  colspan ="3"  align ="right" > &nbsp; </ td >
 
  
</ tr >
 
  
< tr >
 
      
< td > &nbsp; </ td >
 
    
< td  width ="100" align ="right"  style ="border:1px solid #CCCCCC; font-size:12px;" >  请输入新密码:  </ td >
 
    
< td  width ="120" >   < input  name ="newPwd"  type ="password"  id ="newPwd"  maxlength ="6"  style ="width:135px" ></ td >
 
    
< td > &nbsp; </ td >
 
  
</ tr >
 
  
< tr >
 
      
< td > &nbsp; </ td >
 
    
< td  width ="100"  align ="right"  style ="border:1px solid #CCCCCC; font-size:12px;" >  请确认新密码:  </ td >
 
    
< td  width ="120" >   < input  name ="confirmPwd"  type ="password"  id ="confirmPwd"  maxlength ="6"  style ="width:135px" ></ td >
 
    
< td > &nbsp; </ td >
 
  
</ tr >
 
</ table >
 
< table  width ="100%"  height ="60"  border ="0"  cellpadding ="0"  cellspacing ="0" >
 
  
< tr  align ="center" >
 
    
< td > &nbsp; </ td >
 
    
< td  width ="65" >   < input  name ="ok"  type ="button"  class ="btn_70"  id ="ok"  value ="确 定"  onClick ="modifyPwd()" ></ td >
 
    
< td  width ="15" > &nbsp; </ td >
 
    
< td  width ="65" >   < input  name ="reset"  type ="button"  class ="btn_70"  id ="reset"  value ="重 置"  onClick ="resetConfirmPwd()" ></ td >
 
    
< td  width ="15" > &nbsp; </ td >
 
    
< td  width ="65" >   < input  name ="close"  type ="button"  class ="btn_70"  id ="close"  value ="关 闭"  onClick ="window.close()" >   </ td >
 
    
< td > &nbsp; </ td >
 
  
</ tr >
 
</ table >
 
</ body >

</ html >


马嘉楠
jianan.ma@gmail.com

posted on 2006-12-07 11:25 马嘉楠 阅读(876) 评论(0)  编辑  收藏 所属分类: SoureCodeJava Script

只有注册用户登录后才能发表评论。


网站导航: