Last active
August 29, 2015 14:16
-
-
Save eightdotthree/f22a3e14d7e71ce5f016 to your computer and use it in GitHub Desktop.
Populate email field from email param
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Function: getUrlParameters | |
Description: Get the value of URL parameters either from current URL or static URL | |
Author: Tirumal | |
URL: www.code-tricks.com | |
*/ | |
getUrlParameters: function (parameter, staticURL, decode) { | |
var currLocation = (staticURL.length) ? staticURL : window.location.search, | |
parArr = currLocation.split('?')[1].split('&'), | |
returnBool = true; | |
for (var i = 0; i < parArr.length; i += 1) { | |
var parr = parArr[i].split('='); | |
if (parr[0] === parameter) { | |
returnBool = true; | |
return (decode) ? decodeURIComponent(parr[1]) : parr[1]; | |
} else { | |
returnBool = false; | |
} | |
} | |
if (!returnBool) { | |
return false; | |
} | |
} | |
populateEmailField: function (field) { | |
var email = this.getUrlParameters('email', '', true); | |
$(field).val(email); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment