初學jsRegex之密碼強度驗證

來源:互聯網
上載者:User

標籤:xhtml 1.0   head   xhtml   運算式   password   amp   public   logs   exe   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">  <head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <title>passwordCheck</title>  <script type="text/javascript" src="Js/jquery1.6.1.js"></script>  <script type="text/javascript">      $(function() {          $(‘#pwd‘).keyup(function() {              var val = $(this).val();              isDigit(val);          });                    function isDigit(s) {              var pattern_d = /^\d+$/;            //全數字              var pattern_s = /^[A-Za-z]+$/       //全字元              var pattern_w = /^\w+$/;            //數字或者字元              var pattern_W = /^\W+$/             //全非數字也非字元              var pattern_r = /^\w+\W+[\w\W]*\w+$/    //以字母或者數字開頭結尾的字串              var html = ‘‘;              var x = 0;              var y = 0;                            $(‘#user‘).html(s);              if(pattern_W.exec(s)) {                  html += ‘非數字也非字元<br />‘;                  x = 0;                  y = 0;              }              if(pattern_w.exec(s)) {                  html += ‘數字或者字元<br />‘;                  y = 1;              }              if(pattern_d.exec(s)) {                  html += ‘全數字<br />‘;                  x = 1;                  y = 0;              }              if(pattern_s.exec(s)) {                  html += ‘全字元<br />‘;                  x = 2;                  y = 0;              }              if(pattern_r.exec(s)) {                  html += ‘以字母或者數字開頭結尾的字串<br />‘;                  x = 3;                  y = 2;              }              if( y === 0 && x === 0) {                  html += ‘密碼格式錯誤<br />‘;              }              if( x > 0 && y === 0) {                  html += ‘安全層級《低》<br />‘;              }              if( x === 0 && y === 1) {                  html += ‘安全層級《中》<br />‘;              }              if( y === 2) {                  html += ‘安全層級《高》<br />‘;              }              html += x + ‘<br />‘ + y;              $(‘#password‘).html(html);          };      });  </script>  </head>    <body>  <form action="#" method="#">      使用者名稱:<input type="text" name="" /><span id="user"></span><br />      密碼:<input type="password" name="" id="pwd" /><span id="password"></span><br />  </form>  </body>  </html>  

  

初學jsRegex之密碼強度驗證

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.