Skip to content

Instantly share code, notes, and snippets.

@komplexb
Created September 6, 2014 12:55
Show Gist options
  • Save komplexb/fe514e60647931d8da8e to your computer and use it in GitHub Desktop.
Save komplexb/fe514e60647931d8da8e to your computer and use it in GitHub Desktop.
<form id="provcon-form-email" target="_self" onsubmit="" action="javascript:postProvConToGoogleEmail()" style="display:none">
<div class="alert alert-dismissable alert-warning text-center">
Thanks!
<br>
If you tell us your e-mail address, someone from our team will get back to you very soon to explore how you can start saving!
</div>
<div class="form-group">
<label for="email" class="h4">Email</label>
<input
required="required"
id="email"
type="email"
pattern="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"
name="email"
class="form-control"
placeholder="email@domain.com">
</div>
<div class="clear">
<input
type="submit"
value="Get in touch!"
name="submit"
id="send"
class="btn-success btn-lg btn-block">
</div>
</form>
<div style="display:none" class="tryit-submitted alert alert-dismissable alert-warning text-center">
Thanks!
<br>
We'll get back to you very soon to explore how you can start saving!
</div>
function postProvConToGoogleEmail() {
var insurer = $("#insurer").val();
var medication = $("#medication").val();
var email = $('#email').val();
var postUrl = "";
if ((insurer !== "") && (email !== "") && ((medication !== "") && (validateEmail(email)))) {
$.ajax({
url: postUrl,
data: {
"entry.664435950" : insurer,
"entry.1941006211" : medication,
"entry.2103849256": email
},
type: "POST",
dataType: "xml",
statusCode: {
0: function () {
$("#provcon-form-email").hide();
$(".tryit-submitted").show();
//Success message
},
200: function () {
$("#provcon-form-email").hide();
$(".tryit-submitted").show();
//Success Message
}
}
});
}
else {
//Error message
}
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment