Created
July 30, 2017 07:29
-
-
Save misujon/e1edf6242dfda77a121578a7598cb1c9 to your computer and use it in GitHub Desktop.
Market-Sharp Auto responder Integration Codes
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
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js"></script> | |
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.pack.js"></script> | |
<script> | |
function textCounter( field, spanId, maxlimit ) { | |
if ( field.value.length > maxlimit ) | |
{ | |
field.value = field.value.substring( 0, maxlimit ); | |
alert( 'Textarea value can only be ' + maxlimit + ' characters in length.' ); | |
return false; | |
} | |
else | |
{ | |
jQuery('#'+spanId).text('' + (maxlimit - field.value.length) + ' characters remaining'); | |
} | |
} | |
jQuery(document).ready(function(){ | |
jQuery.validator.addMethod( | |
"phoneUS", function(phone_number, element) { | |
phone_number = phone_number.replace(/\s+/g, ""); | |
return this.optional(element) || phone_number.length > 9 && | |
phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/); | |
}, | |
"Please specify a valid phone number(example:222-222-2222)" | |
); | |
jQuery('#SubmitButton').click(function(evt) { | |
var isValid = jQuery('form').valid(); | |
<!--if (!isValid)--> | |
evt.preventDefault(); | |
if (isValid) | |
{ | |
jQuery("div.error").hide(); | |
/*jQuery("body").append('<form id="form-to-submit" style="visibility:hidden;"></form>'); | |
jQuery("#form-to-submit").html(jQuery("#marketsharpmFieldSet").clone());*/ | |
var textareaData = new Array(); | |
jQuery.each(jQuery("#marketsharpmFieldSetDiv textarea"), function(index, value) { | |
var cleanValue = escape(jQuery.trim(value.value)); | |
if (cleanValue !== '') | |
textareaData[value.name] = cleanValue; | |
}); | |
var selectData = new Array(); | |
jQuery.each(jQuery("#marketsharpmFieldSetDiv select"), function(index, value) { | |
var cleanValue = escape(jQuery.trim(value.value)); | |
if (cleanValue !== '') | |
selectData[value.name] = cleanValue; | |
}); | |
/*var values = jQuery("#form-to-submit").serialize();*/ | |
var values = jQuery("#marketsharpmForm").serialize(); | |
if (values == '') | |
{ | |
jQuery("body").append('<form id="form-to-submit" style="visibility:hidden;"></form>'); | |
jQuery("#form-to-submit").html(jQuery("#marketsharpmFieldSet").clone()); | |
values = jQuery("#form-to-submit").serialize(); | |
} | |
/*Perform manual check for Phone or Email (at least one is required)*/ | |
var email = jQuery("#form-to-submit #MSM_email").val(); | |
var homePhone = jQuery("#form-to-submit #MSM_homephone").val(); | |
if(email === '' && homePhone) | |
{ | |
jQuery("div.error span").html("Phone or Email is required."); | |
jQuery("div.error").show(); | |
return false; //short-circuit | |
} | |
for(var keyName in selectData) { | |
var regEx = new RegExp("&" + keyName + "=[^&]*", "gi"); | |
var allSelectData = regEx.exec(values); | |
values = values.replace(allSelectData, "&" + keyName + "=" + selectData[keyName]); | |
} | |
for(var keyName in textareaData) { | |
var regEx = new RegExp("&" + keyName + "=[^&]*", "gi"); | |
var allInterestData = regEx.exec(values); | |
values = values.replace(allInterestData, "&" + keyName + "=" + textareaData[keyName]); | |
} | |
values = values.replace(/&/g, "&|&"); | |
//console.log('values: ', JSON.stringify(values)); | |
/*jQuery("#form-to-submit").remove();*/ | |
jQuery.getJSON("https://ha.marketsharpm.com/LeadCapture/MarketSharp/LeadCapture.ashx?callback=?", | |
{ "info": values, "version" : 2 }, | |
function(data, msg) { | |
jQuery("div.error span").html(""); | |
if (data.errors.length > 0) | |
{ | |
jQuery.each(data.errors, function() { | |
jQuery("div.error span").append(this + "<br />"); | |
}); | |
jQuery("div.error span br:last").remove(); | |
jQuery("div.error").show(); | |
} | |
else if (data.redirectUrl != '') | |
{ | |
window.location.replace(data.redirectUrl); | |
} | |
else if (data.msg == 'success') | |
{ | |
jQuery('#marketsharpmFieldSetDiv').html("<div id='message' style='text-align: center;'></div>"); | |
jQuery('#message').html("<h2>Contact Information Submitted!</h2>") | |
.append("<p>We will be in touch soon.</p>") | |
.hide() | |
.fadeIn(1500, function() { | |
jQuery('#message').append(""); | |
}); | |
} | |
else | |
{ | |
jQuery("div.error span").html("There was an unknown error submitting the form."); | |
jQuery("div.error").show(); | |
} | |
} | |
); | |
return false; | |
} | |
}); | |
jQuery("form").validate({ | |
onsubmit: false, | |
invalidHandler: function(e, validator) { | |
var errors = validator.numberOfInvalids(); | |
if (errors) { | |
var message = errors == 1 | |
? 'You missed 1 field. It has been highlighted below' | |
: 'You missed ' + errors + ' fields. They have been highlighted below'; | |
jQuery("div.error span").html(message); | |
jQuery("div.error").show(); | |
} else { | |
jQuery("div.error").hide(); | |
} | |
}, | |
onkeyup: false | |
}); | |
}); | |
</script> | |
<style type="text/css"> | |
#marketsharpmFormDiv input { | |
border-spacing: 0px; | |
margin: 0px; | |
padding: 10px; | |
space: 0px; | |
margin-bottom: 15px; | |
} | |
#marketsharpmFormDiv .submit { | |
text-align: left; | |
margin-left: 15px; | |
border: 0; | |
border-radius: 5px; | |
} | |
#marketsharpmFormDiv label.error { | |
color: red; | |
float: none; | |
display: inline; | |
margin-left: 0.5em; | |
} | |
#marketsharpmFormDiv p input.error { | |
background-color: #FFFFD5; | |
border-bottom-color: red; | |
border-bottom-style: solid; | |
border-bottom-width: 2px; | |
border-left-color-ltr-source: physical; | |
border-left-color-rtl-source: physical; | |
border-left-color-value: red; | |
border-left-style-ltr-source: physical; | |
border-left-style-rtl-source: physical; | |
border-left-style-value: solid; | |
border-left-width-ltr-source: physical; | |
border-left-width-rtl-source: physical; | |
border-left-width-value: 2px; | |
border-right-color-ltr-source: physical; | |
border-right-color-rtl-source: physical; | |
border-right-color-value: red; | |
border-right-style-ltr-source: physical; | |
border-right-style-rtl-source: physical; | |
border-right-style-value: solid; | |
border-right-width-ltr-source: physical; | |
border-right-width-rtl-source: physical; | |
border-right-width-value: 2px; | |
border-top-color: red; | |
border-top-style: solid; | |
border-top-width: 2px; | |
border-right-color: red; | |
border-right-style: solid; | |
border-right-width: 2px; | |
border-left-color: red; | |
border-left-style: solid; | |
border-left-width: 2px; | |
color: red; | |
margin-bottom: 0; | |
margin-left: 0; | |
margin-right: 0; | |
margin-top: 0; | |
} | |
#marketsharpmFormDiv div.error { | |
text-align: center; | |
color: red; | |
} | |
#marketsharpmFormDiv .hidden { | |
display: none; | |
} | |
</style> | |
<div id="marketsharpmFormDiv"> | |
<h3>Contact Us Here</h3> | |
<form id="marketsharpmForm" method="post" action="https://ha.marketsharpm.com/LeadCapture/MarketSharp/LeadCapture.ashx"> | |
<fieldset id="marketsharpmFieldSet" > | |
<div id="marketsharpmFieldSetDiv"> | |
<div class="error" style="display:none;"> | |
<span></span><br clear="all" /> | |
</div> | |
<p><label for="MSM_firstname"></label><input id="MSM_firstname" type="text" name="MSM_firstname" placeholder="First Name" class="required" maxlength="50" /></p> | |
<p><label for="MSM_lastname"></label><input id="MSM_lastname" type="text" name="MSM_lastname" placeholder="Last Name" class="required" maxlength="50" /></p> | |
<p><label for="MSM_zip"></label><input id="MSM_zip" type="text" name="MSM_zip" placeholder="Zip" maxlength="50" /></p> | |
<p><label for="MSM_email"></label><input id="MSM_email" type="text" name="MSM_email" placeholder="Email" class=" email" maxlength="100" /></p> | |
<p><label for="MSM_homephone"></label><input id="MSM_homephone" type="text" name="MSM_homephone" placeholder="Phone" class=" phoneUS" maxlength="15" /></p> | |
<p class="submit"><input type="submit" id="SubmitButton" name="submitbutton" value="Submit Info" class="submit" /></p> | |
<input type="hidden" name="MSM_source" value="cc2025b0-c53c-4865-9db7-8028ec23c8d7" /> | |
<input type="hidden" name="MSM_coy" value="2954" /> | |
<input type="hidden" name="MSM_formId" value="cc2025b0-c53c-4865-9db7-8028ec23c8d7" /> | |
<input type="hidden" name="MSM_leadCaptureName" value="MarketSharp" /> | |
</div> | |
</fieldset> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment