IF user name and password found in local storage go to index2 with user name and password

IF user name and password found in local storage go to index2 with user name and password

I have two page
index.html source page
index2.html destination
in source page (index.html) i have two input boxes for user name and password and check box remember me  and button login
1-if client write user name and password then checkbox remember me checked
then it will store data of user name and password in local storage
when open web application again it must open index2.html directly and 
index2.html have user name and password in this case
2- if check box not checked it will not store data of user name and password in local storage
in first case when remember me checkbox checked then click login it will store data in local storage
my problem i cannot do validation to local storage meaning
sot that i need to make following
if local storage of user name and password stored in local storage then go to index2 with user name and password stored in local storage
index.html

  1. @{
  2.     Layout = null;
  3. }

  4. <!DOCTYPE html>

  5. <html>
  6. <head>
  7.     <meta name="viewport" content="width=device-width" />
  8.     <title>Index</title>
  9.     <script src="~/Scripts/jquery-1.10.2.js"></script>
  10.     <script>
  11.         $(function () {

  12.             if (localStorage.chkbx && localStorage.chkbx != '') {
  13.        
  14.                 window.location.href = "/test/index2";
  15.             } else {
  16.                 $('#remember_me').removeAttr('checked');
  17.                 $('#username').val('');
  18.                 $('#pass').val('');
  19.             }

  20.             $('#btn').click(function () {

  21.                 if ($('#remember_me').is(':checked')) {
  22.                     // save username and password
  23.                     localStorage.usrname = $('#username').val();
  24.                     localStorage.pass = $('#pass').val();
  25.                     localStorage.chkbx = $('#remember_me').val();
  26.                    var url = "/test/index2?name=" + encodeURIComponent($("#username").val()) + "&pass=" + encodeURIComponent($("#pass").val());
  27.                    window.location.href = url;
  28.                 } else {
  29.                     localStorage.usrname = '';
  30.                     localStorage.pass = '';
  31.                     localStorage.chkbx = '';
  32.                 }
  33.             });
  34.         });
  35.     </script>
  36. </head>
  37. <body>
  38.     <div class="container">
  39.         <form class="form-signin">
  40.             <h2 class="form-signin-heading">Please sign in</h2>
  41.             <input type="text" class="input-block-level" placeholder="Email address" name="name" id='username'>
  42.             <input type="password" class="input-block-level" placeholder="Password" name="pass" id="pass">
  43.             <label class="checkbox">
  44.                 <input type="checkbox" value="remember-me" id="remember_me"> Remember me
  45.             </label>
  46.             <button class="btn btn-large btn-primary" type="submit" id="btn">Sign in</button>
  47.         </form>
  48.     </div> 
  49. </body>
  50. </html>
index2.html destination page

  1. @{
  2.     Layout = null;
  3. }

  4. <!DOCTYPE html>

  5. <html>
  6. <head>
  7.     <meta name="viewport" content="width=device-width" />
  8.     <title>Index2</title>
  9.     <script src="~/Scripts/jquery-1.10.2.js"></script>
  10.     <script>
  11.         var queryString = new Array();
  12.         $(function ()
  13.         {
  14.             if (queryString.length == 0) {
  15.                if (window.location.search.split('?').length > 1) {
  16.                    var params = window.location.search.split('?')[1].split('&');
  17.                    for (var i = 0; i < params.length; i++) {
  18.                        var key = params[i].split('=')[0];
  19.                         var value = decodeURIComponent(params[i].split('=')[1]);
  20.                         queryString[key] = value;
  21.                     }
  22.                 }
  23.             }
  24.            if (queryString["name"] != null && queryString["pass"] != null) {
  25.                var data = "<u>Values from QueryString</u><br /><br />";
  26.                data += "<b>Name:</b> " + queryString["name"] + " <b>pass:</b> " + queryString["pass"];
  27.                $("#lblData").html(data);
  28.             }
  29.     $("#btn").click(function ()
  30.     {
  31.         localStorage.clear();
  32.     });
  33.     });


  34.     </script>
  35. </head>
  36. <body>
  37.   Welcom 
  38.     <span id="lblData"></span>
  39.     <input type="button" value="clear" id="btn" />
  40. </body>
  41. </html>


sorry i cannot do that in fiddle because this is two pages