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
- @{
- Layout = null;
- }
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width" />
- <title>Index</title>
- <script src="~/Scripts/jquery-1.10.2.js"></script>
- <script>
- $(function () {
- if (localStorage.chkbx && localStorage.chkbx != '') {
-
- window.location.href = "/test/index2";
- } else {
- $('#remember_me').removeAttr('checked');
- $('#username').val('');
- $('#pass').val('');
- }
- $('#btn').click(function () {
- if ($('#remember_me').is(':checked')) {
- // save username and password
- localStorage.usrname = $('#username').val();
- localStorage.pass = $('#pass').val();
- localStorage.chkbx = $('#remember_me').val();
- var url = "/test/index2?name=" + encodeURIComponent($("#username").val()) + "&pass=" + encodeURIComponent($("#pass").val());
- window.location.href = url;
- } else {
- localStorage.usrname = '';
- localStorage.pass = '';
- localStorage.chkbx = '';
- }
- });
- });
- </script>
- </head>
- <body>
- <div class="container">
- <form class="form-signin">
- <h2 class="form-signin-heading">Please sign in</h2>
- <input type="text" class="input-block-level" placeholder="Email address" name="name" id='username'>
- <input type="password" class="input-block-level" placeholder="Password" name="pass" id="pass">
- <label class="checkbox">
- <input type="checkbox" value="remember-me" id="remember_me"> Remember me
- </label>
- <button class="btn btn-large btn-primary" type="submit" id="btn">Sign in</button>
- </form>
- </div>
- </body>
- </html>
index2.html destination page
- @{
- Layout = null;
- }
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width" />
- <title>Index2</title>
- <script src="~/Scripts/jquery-1.10.2.js"></script>
- <script>
- var queryString = new Array();
- $(function ()
- {
- if (queryString.length == 0) {
- if (window.location.search.split('?').length > 1) {
- var params = window.location.search.split('?')[1].split('&');
- for (var i = 0; i < params.length; i++) {
- var key = params[i].split('=')[0];
- var value = decodeURIComponent(params[i].split('=')[1]);
- queryString[key] = value;
- }
- }
- }
- if (queryString["name"] != null && queryString["pass"] != null) {
- var data = "<u>Values from QueryString</u><br /><br />";
- data += "<b>Name:</b> " + queryString["name"] + " <b>pass:</b> " + queryString["pass"];
- $("#lblData").html(data);
- }
- $("#btn").click(function ()
- {
- localStorage.clear();
- });
- });
- </script>
- </head>
- <body>
- Welcom
- <span id="lblData"></span>
- <input type="button" value="clear" id="btn" />
- </body>
- </html>
sorry i cannot do that in fiddle because this is two pages