【www.gdgbn.com--正则表达式】

 





js验证密码
<script language="网页特效">
function chkpwd(obj){
  var t=obj.value;
  var id=getresult(t);
  var msg=new array(4);
  msg[0]="密码小于6个字符。";
  msg[1]="密码强度一般。";
  msg[2]="密码强度良好。";
  msg[3]="密码强度高。";
  var sty=new array(4);
  sty[0]=-45;
  sty[1]=-30;
  sty[2]=-15;
  sty[3]=0;
  var col=new array(4);
  col[0]="gray";
  col[1]="red";
  col[2]="#ff6600";
  col[3]="green";
  var bimg="../images/passwordjc.gif";
  var swidth=300;
  var sheight=15;
  var bobj=document.getelementbyid("chkresult");
  bobj.style.fontsize="12px";
  bobj.style.color=col[id];
  bobj.style.width=swidth + "px";
  bobj.style.height=sheight + "px";
  bobj.style.lineheight=sheight + "px";
  bobj.style.background="url(" + bimg + ") no-repeat left " + sty[id] + "px";
  bobj.style.textindent="20px";
  bobj.innerhtml="检测提示:" + msg[id];
 }
 function getresult(s){
  if(s.length < 4){
   return 0;
  }
  var ls = 0;
  if (s.match(/[a-z]/ig)){
   ls++;
  }
  if (s.match(/[0-9]/ig)){
   ls++;
  }
   if (s.match(/(.[^a-z0-9])/ig)){
   ls++;
  }
  if (s.length < 6 && ls > 0){
   ls--;
  }
  return ls
 }
</script>




密  码:* 
                  word" class="user_reg_button" id="user_pass" size="25" maxlength="20" onblur="chkpwd(this)" />
                  由字母、数字、下划线组成(6-20位)
               
               
                  再次输入密码:* 
                 
               
               

本文来源:http://www.gdgbn.com/aspjiaocheng/27646/