Skip to content

Instantly share code, notes, and snippets.

@bspindler
Last active November 10, 2017 22:37
Show Gist options
  • Save bspindler/6a8e781ac47d725f8511dc48c757c130 to your computer and use it in GitHub Desktop.
Save bspindler/6a8e781ac47d725f8511dc48c757c130 to your computer and use it in GitHub Desktop.
signup form
<form id="signupForm" action="https://uat.metricly.com/signupAndProvision" onsubmit="addFields();" method="post" >
<input id="firstName" maxlength="40" name="firstName" placeholder="First Name" size="40" type="text" /><br/><br />
<input id="lastName" maxlength="80" name="lastName" placeholder="Last Name" size="40" type="text" /><br><br />
<input id="title" maxlength="40" name="title" placeholder="Title" size="40" type="text" /><br><br />
<input id="company" maxlength="40" name="company" placeholder="Company" size="40" type="text" required /><br>
<div id="companyError" style="font-size: small; color: red;"></div><br />
<input id="email" maxlength="80" name="email" placeholder="Email" size="40" type="text" required /><br>
<div id="emailError" style="font-size: small; color: red;"></div><br />
<input id="phone" maxlength="40" name="phone" placeholder="Phone" size="40" type="text" /><br><br />
<input id="password" maxlength="40" name="password" placeholder="password" size="40" type="password" required /><br><br />
<input type="submit" value="Start your trial now!" /><br />
</form>
<script>
document.getElementById("companyError").innerHTML = "";
document.getElementById("emailError").innerHTML = "";
var queryStr = window.location.search;
var paramPairs = queryStr.substr(1).split('&');
var params = {};
for (var i = 0; i < paramPairs.length; i++) {
var parts = paramPairs[i].split('=');
params[parts[0]] = parts[1];
}
if(params.error) {
if(params.error == 1) {
document.getElementById("companyError").innerHTML = "Company name is already taken, please choose another. ";
}
if(params.error == 2) {
document.getElementById("emailError").innerHTML = "Email is already taken, please choose another.";
}
}
function addFields() {
var form = document.getElementById("signupForm");
var input = document.createElement("input");
input.hidden = "true";
input.type = "text";
input.name = "fullName";
input.value = document.getElementById("firstName").value + " " + document.getElementById("lastName").value;
form.appendChild(input);
var input = document.createElement("input");
input.hidden = "true";
input.type = "text";
input.name = "utmCampaign";
input.value = getCookie('utm_campaign');
form.appendChild(input);
var input = document.createElement("input");
input.hidden = "true";
input.type = "text";
input.name = "utmKeyword";
input.value = getCookie('utm_keyword');
form.appendChild(input);
var input = document.createElement("input");
input.hidden = "true";
input.type = "text";
input.name = "utmMedium";
input.value = getCookie('utm_medium');
form.appendChild(input);
var input = document.createElement("input");
input.hidden = "true";
input.type = "text";
input.name = "utmSource";
input.value = getCookie('utm_source');
form.appendChild(input);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment