I have web page index have two input type text username and username2and checkbox save and button save when client write username and username2 and checkbox save checked then click save buttonit will store in local storage i dont have any problem in that I need actually if username and username2 exist or stored in local storage go to web page index2my code as bellow working but only i need to modify it if exist local storage go to web page index2
- @{
- 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 != '') {
- $('#save').attr('checked', 'checked');
- $('#username').val(localStorage.username);
- $('#username2').val(localStorage.username2);
- } else {
- $('#remember_me').removeAttr('checked');
- $('#username').val('');
- $('#username2').val('');
- }
-
- $('#btn').click(function () {
-
- if ($('#save').is(':checked')) {
-
- localStorage.username = $('#username').val();
- localStorage.username2 = $('#username2').val();
- localStorage.chkbx = $('#save').val();
- } else {
- localStorage.username = '';
- localStorage.username2 = '';
- 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="username" id='username'>
- <input type="text" class="input-block-level" placeholder="username2" id="username2">
- <label class="checkbox">
- <input type="checkbox" value="save" id="save"> save
- </label>
- <button class="btn btn-large btn-primary" id="btn" type="submit">save</button>
- </form>
- </div>
- </body>
- </html>