title: Save to LocalStorage on a condition
body: <p>I've script two script that i want to merge as one  . Script 1 is for checking if email and password is right it brings out a success message "Correct" and it logs you in. Script 2 is what i use to store the email and password in a localstorge</p>
  
  <p>Script 1</p>
  
  <pre><code>$(document).ready(function(){
      $("#form1").on('submit',function(event){
          event.preventDefault();
  
          data = $(this).serialize();
          $.ajax({
          type: "POST",
  
          url: "log.asp",
          data: data,
    success: function(data) {
        $('#log_msg').html(data);
  
      var result = $.trim(data);
  
      if(result==="Correct"){
         window.location = 'source.asp';
  
      }
    }
  
  });
  });
  });
  </code></pre>
  
  <p>Script 2</p>
  
  <pre><code>$(function() {
    var
      $email = $('#email'),
      $password = $('#password'),
      localEmail = localStorage.getItem("eaddress"),
      localPwd = localStorage.getItem("pwd");
  
  
    // SAVE VARIABLES TO LOCAL STORAGE
    $('#form1').on('submit', function() {
      localStorage.setItem("eaddress", $email.val());
      localStorage.setItem("pwd", $password.val());
    });
  
  });
  </code></pre>
  
  <p>Now i want to merge the two together that it should only save the email and password in the localstorge if the success message is equal
  to <code>"Correct"</code> and also logs you in</p>