熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

Javascript實現論壇中常見的密碼強度提示[2]

2022-06-13   來源: JSP教程 
// increase strength if contains non alpha
   non_alpha_re = new RegExp([^AZaz]);
   if (non_alpha_retest(input_str)) {
    strength++;
   }
   // increase strength if contains upper case
   upper_alpha_re = new RegExp([AZ]);
   if (upper_alpha_retest(input_str)) {
    strength++;
   }
   // increase strength if long enough
   if(input_length >=) {
    strength++;
   }
   var strength_str;
   if (strength <= ) {
    strength_str = <strong style=color:blue>弱</strong>;
   } else if (strength <= ) {
    strength_str = <strong style=color:blue>中等</strong>;
   } else {
    strength_str = <strong style=color:green>強壯</strong>;
   }
   if(input_strlength < ) {
    strength_str = <strong style=color:orange>太弱</strong>;
   }
   output_displayinnerHTML  = strength_str;
  }
  </script>
  <div>
  <span>密碼強度: </span>
  <span id=reg_passwd__strength_display__>
  </span>
  </div>
  </div>
  </form>
  </body>
  </html>

[]  []  


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20663.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.