最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS+HTML5本地存儲(chǔ)Localstorage實(shí)現(xiàn)注冊(cè)登錄及驗(yàn)證功能示例

 更新時(shí)間:2020年02月10日 10:35:05   作者:張成的csdn  
這篇文章主要介紹了JS+HTML5本地存儲(chǔ)Localstorage實(shí)現(xiàn)注冊(cè)登錄及驗(yàn)證功能,結(jié)合實(shí)例形式分析了基于JS+HTML5本地存儲(chǔ)Localstorage實(shí)現(xiàn)注冊(cè)登錄及驗(yàn)證相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了JS+HTML5本地存儲(chǔ)Localstorage實(shí)現(xiàn)注冊(cè)登錄及驗(yàn)證功能。分享給大家供大家參考,具體如下:

源碼引用的js、jquery都是在線的,代碼拷到本地就能運(yùn)行

登錄:

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>登錄</title>
    <link  rel="external nofollow" rel="external nofollow" rel="stylesheet">
    <script src="https://cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
  </head>
  <body>
  <div class="bar bar-header">
   <div class="h1 title">登錄</div>
  </div>
  <div class="content has-header">
   <div class="list">
    <label class="item item-input">
     <span class="input-label">用戶名:</span>
     <input id="loginName" type="text">
    </label>
    <label class="item item-input">
     <span class="input-label">密碼:</span>
     <input id="loginPsd" type="password">
    </label>
   </div>
   <div class="padding">
    <button οnclick="login()" class="button button-block button-positive">登錄</button>
   </div>
  </div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script>function login(){if(NoKong()){if(localStorage.user){arr = eval(localStorage.user);//獲取localStoragevar k = 0;for(e in arr){if($('#loginName').val()==arr[e].loginName){if($('#loginPsd').val()==arr[e].loginPsd){alert('登錄成功');clear();k = 0;return;}else{alert('密碼錯(cuò)誤');clear();k = 0;return;}}else{ k = 1;}}if(k==1){alert('用戶名不存在');clear();}}else{alert('用戶名不存在');clear();}}}function clear(){$('#loginName').val('');$("#loginPsd").val('');}function NoKong(){if($('#loginName').val()==""){alert('用戶名不能為空');return false;}else if($('#loginPsd').val()==""){alert('密碼不能為空');return false;}return true;}</script> </body></html>

注冊(cè):

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>注冊(cè)</title>
    <link  rel="external nofollow" rel="external nofollow" rel="stylesheet">
    <script src="https://cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
  </head>
  <body>
  <div class="bar bar-header">
   <div class="h1 title">注冊(cè)</div>
  </div>
  <div class="content has-header">
   <div class="list">
    <label class="item item-input">
     <span class="input-label">用戶名:</span>
     <input id="loginName" type="text">
    </label>
    <label class="item item-input">
     <span class="input-label">密碼:</span>
     <input id="loginPsd" type="password">
    </label>
   </div>
   <div class="padding">
    <button οnclick="ZhuCe()" class="button button-block button-positive">注冊(cè)</button>
   </div>
  </div>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
 <script>
 function ZhuCe(){
 if(NoKong()){
  var arr = [];
  if(localStorage.user){
  arr = eval(localStorage.user);
  for(e in arr){
   if($('#loginName').val()==arr[e].loginName){
   alert('該賬號(hào)已被注冊(cè)');
   clear();
   return;
   }
  }
  }
  var user = {'loginName':$("#loginName").val(),'loginPsd':$("#loginPsd").val()};
  arr.push(user);
  localStorage.user=JSON.stringify(arr);
  alert('注冊(cè)成功');
  clear();
  }
 }
 function clear(){
  $('#loginName').val('');
  $("#loginPsd").val('');
 }
 function NoKong(){
  if($('#loginName').val()==""){
  alert('用戶名不能為空');
  return false;
  }else if($('#loginPsd').val()==""){
  alert('密碼不能為空');
  return false;
  }
  return true;
 }
 </script>
 </body>
</html>

更多關(guān)于JavaScript相關(guān)內(nèi)容還可查看本站專題:《JavaScript+HTML5特效與技巧匯總》、《JavaScript圖形繪制技巧總結(jié)》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

阳曲县| 郸城县| 凤凰县| 江陵县| 周宁县| 镇雄县| 通河县| 象州县| 拉孜县| 云梦县| 和田县| 龙胜| 米易县| 海丰县| 奈曼旗| 庄浪县| 介休市| 平昌县| 钟祥市| 平邑县| 东安县| 封开县| 隆安县| 阿尔山市| 房山区| 曲周县| 囊谦县| 玛纳斯县| 松滋市| 勃利县| 林口县| 康定县| 江华| 儋州市| 于田县| 平安县| 峨眉山市| 绥滨县| 永修县| 唐山市| 平南县|