Article

Storing form data with cookies.

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

We can store data submitted by a user in a cookie.

Cookies will allow us to hold data even when we navigate away from the page.

For example we may want to remember a user's name as he navigates from one page to another.

We can do this by: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/forms/ex16.js?actionable=true

Note that the above example use an external library, js-cookie, to easily store information in cookies. (See the demo code listing for the full script.)

We can then retrieve the stored information by using the following code: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/forms/ex17.js?actionable=true Head over to our cookies page for more information about the subject.

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<div id="minidivpage" class="example-live"><h4 class="heading-4">Webflow form:</h4><h5 class="message">Message Text</h5><div class="w-form"><form id="email-form" name="email-form" data-name="Email Form" method="get" aria-label="Email Form"><label for="name">Name</label><input type="text" class="w-input" maxlength="256" name="Name" data-name="Name" placeholder="" id="name"><input type="submit" value="Submit" data-wait="Please wait..." class="w-button"></form><div class="w-form-done" tabindex="-1" role="region" aria-label="Email Form success"><div>Thank you! Your submission has been received!</div></div><div class="w-form-fail" tabindex="-1" role="region" aria-label="Email Form failure"><div>Oops! Something went wrong while submitting the form.</div></div></div></div>

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.