欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript實(shí)現(xiàn)密碼驗(yàn)證

 更新時(shí)間:2015年11月10日 14:37:53   投稿:lijiao  
這篇文章主要介紹了javascript密碼驗(yàn)證的實(shí)現(xiàn)方法,過(guò)程很簡(jiǎn)單具有一定的參考價(jià)值,適合初學(xué)者學(xué)習(xí)研究,感興趣的小伙伴們可以參考一下

本文為大家分享了javascript密碼驗(yàn)證的實(shí)現(xiàn)方法,歡迎大家閱讀。

javascript密碼驗(yàn)證代碼如下

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>密碼驗(yàn)證</title>
 <script src="js/jquery-1.11.1.js"></script>
 <script>
  $(function(){
   $(document).on('blur','input',function(){
    var $password=$('#password').val();
    var $password_again=$('#password_again').val();
     if(!$password){
      $("#password").addClass('redBorder').next('label').show().html('不能為空');;
      return false;
     }else if(!$password_again){
      $("#password_again").addClass('redBorder').next('label').show().html('不能為空');
      return false;
     }else{
      $('input').removeClass('redBorder').next('label').empty();
      if($password_again==$password){
       $("#password,#password_again").next('label').show().html('兩次密碼一致').addClass('valid');
      }else if($password_again!=$password){
       $("#password,#password_again").addClass('redBorder').next('label').show().html('兩次密碼不一致').removeClass('valid').addClass('erro');
      }
 
    } 
   })
    
  })
 </script>
 <style>
  .redBorder{
   border: 1px solid red;
  }
  .erro{
   background: url('images/unchecked.gif') no-repeat;
   padding-left: 16px;
  }
  .valid{
   background: url('images/checked.gif') no-repeat;
   width: 16px;
   height: 16px;
  }
 </style>
</head>
<body>
<div>
 <label>
  輸入密碼:<input type="text" placeholder="輸入密碼" id="password">
  <label id="password-erro" class="erro" style="display:none;"></label>
 </label>
 <br><br>
 <label>
  驗(yàn)證密碼:<input type="text" placeholder="輸入相同密碼" id="password_again">
  <label id="password-erro" class="erro" style="display:none;"></label>
 </label>
 <br><br>
 <button style="margin-left:80px;">submit</button>
</div> 
</body>
</html>

希望本文對(duì)大家學(xué)習(xí)javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論