国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JS+HTML5本地存儲Localstorage實現注冊登錄及驗證功能示例

2024-05-06 15:44:18
字體:
來源:轉載
供稿:網友

本文實例講述了JS+HTML5本地存儲Localstorage實現注冊登錄及驗證功能。分享給大家供大家參考,具體如下:

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

登錄:

<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('密碼錯誤');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>

注冊:

<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="ZhuCe()" 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 ZhuCe(){ if(NoKong()){  var arr = [];  if(localStorage.user){  arr = eval(localStorage.user);  for(e in arr){   if($('#loginName').val()==arr[e].loginName){   alert('該賬號已被注冊');   clear();   return;   }  }  }  var user = {'loginName':$("#loginName").val(),'loginPsd':$("#loginPsd").val()};  arr.push(user);  localStorage.user=JSON.stringify(arr);  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>            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 金溪县| 天镇县| 佛冈县| 霞浦县| 黄平县| 随州市| 钟祥市| 砚山县| 福建省| 镇康县| 金川县| 克什克腾旗| 邓州市| 惠水县| 德钦县| 阿勒泰市| 湖南省| 木兰县| 阜南县| 呼和浩特市| 土默特左旗| 河北省| 鄯善县| 三明市| 永德县| 金平| 石城县| 金秀| 台安县| 嘉祥县| 醴陵市| 松溪县| 南城县| 阿拉善右旗| 昆明市| 阿鲁科尔沁旗| 手机| 中方县| 景洪市| 湘西| 大兴区|