Autofill email using Javascript Cookie
Here is a useful JavaScript code snippet which validates email and then saves it in a cookie for pre-filling or auto-fill email addresses in input fields
First to check email address
Paste this code in the head section of your HTML code
Explanation
Most of the upper part check email string, then in the end we need to call our cookieMan function for cookie creation. And this will only happen once the email validates. After cookie creation, we are opening a new thanks.html page for the user
Now Javascript Cookie creation code
Also paste this code in the head section of your html file
Explanation
If no cookie is present, it will create a new cookie with 15 days to expire. CookieMan function is setting the cookie values, its name, value and expiration date. In the end i am calling getCookie function to show already saved email addresses
Now HTML code
Paste this code inside the body section of your html file
Explanation
Please note that if you change the form name to anything else, remember to alter the name in JavaScript code too. Also i am using email input as “from” which is also used in Javascript code so dont get confused
Notes
Source files are for learning purpose only, I have learned these code snippets from other website which i don’t remember so sorry if it belongs to someone else, just link to my original article. Thanks !
Download Source Files
It took me hours to make this freebie, Please take few minutes to register, Thanks.Please Login or Register for access.
Just enjoy this code and share it with others, thanks a lot![]()
2 Responses to “Autofill email using Javascript Cookie”
Leave a Reply











awesome
Fantastic post here. I am eager to read more!