title: JavaScript Cookie Save Form
body: <p>I've been using this <a href="http://www.the-art-of-web.com/javascript/getcookie/" rel="nofollow">tutorial</a> online to try and save the input value for one of my form fields. </p>
  
  <p>So far without any success.</p>
  
  <p>Am I doing something wrong?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var today = new Date();
      var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days
  
      function setCookie(name, value) {
          document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
      }
  
      function storeValues(form)  {
          setCookie("email", form.email-field.value);
          return true;
      }
  
      if(email = getCookie("email")) document.getElementById('login-form').email-field.value = email-field;
  
       function getCookie(name) {
          var re = new RegExp(name + "=([^;]+)");
          var value = re.exec(document.cookie);
          return (value != null) ? unescape(value[1]) : null;
       }
  
       document.write(getCookie("email"));
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="" method="post" id="login-form"&gt;
  &lt;input class="field" type="text" name="email-field" placeholder="e-mail" style="text-transform: lowercase;" autofocus&gt;
  &lt;br&gt;
  &lt;input class="field" type="password" name="pass" placeholder="password"&gt;
  &lt;button type="submit"&gt;&lt;/button&gt;
  </code></pre>