<script type=”text/javascript”>
// Submit the subscriber’s information to CustomerBeach.
// This call with return a boolean to the callback function ‘SubscribeResult(value)’
function Subscribe() {
if (jQuery(‘#txtFName’).val() == ” || jQuery(‘#txtFName’).val() == ”) {
jQuery(‘#lblResult’).html(‘Both Fields Required’);
jQuery(‘#btnSubmit’).prop(‘disabled’, false);
}
else if (IsEmailValid(jQuery(‘#txtEmail’).val())) {
var objFields = {
firstname: jQuery(‘#txtFName’).val()
};
var jsnFields = JSON.stringify(objFields); //serialize the JSON
jQuery.getJSON(‘https://app.customerbeach.com/pub/RESTSub.aspx?key=’ + “F8BT6UWEKWKGW9BBKNW7JJX8H3″ + ‘&email=’ + encodeURIComponent(jQuery(‘#txtEmail’).val()) + ‘&fields=’ + encodeURIComponent(jsnFields) + ‘&group=5JCYZ7Q&start=1’ + ‘&callback=?’, function (json) { });
}
else {
jQuery(‘#lblResult’).html(‘Email Address is Invalid’);
jQuery(‘#btnSubmit’).prop(‘disabled’, false);
}
}
//Subscribe call back function, must exist or a script error will occur
//Response Codes:
//1: Success
//X: Error
//note: this function can be empty, but it’s a good place to show your response if you want
//However, you should at a minimum, re-enable the submit button to prevent a race condition
function SubscribeResult(value) {
if (value == ‘1’) {
jQuery(‘#lblResult’).html(‘Thank you for subscribing to our newsletter!’);
}
else if (value == ‘201’ || value == ‘203’) {
jQuery(‘#lblResult’).html(‘You are already subscribed’);
}
else {
jQuery(‘#lblResult’).html(‘System Error: ‘ + value);
}
jQuery(‘#btnSubmit’).prop(‘disabled’, false);
}
function IsEmailValid(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&’\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&’\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
}
</script>
<div id=”lblResult” style=”text-align:left; color:red;”>
</div>
<div id=”fscf_div_clear1_0″ style=”clear:both;”>
<div id=”fscf_div_field1_0″ style=”clear:left; float:left; width:99%; max-width:550px; margin-right:10px;”>
<div style=”text-align:left; padding-top:5px;”>
<label style=”text-align:left;” for=”fscf_name1″>Name:<span style=”text-align:left;”>*</span></label>
</div>
<div style=”text-align:left;”>
<input style=”text-align:left; margin:0; width:99%; max-width:250px;” type=”text” id=”txtFName” name=”txtFname” value=””>
</div>
</div>
</div>
<div id=”fscf_div_clear1_1″ style=”clear:both;”>
<div id=”fscf_div_field1_1″ style=”clear:left; float:left; width:99%; max-width:550px; margin-right:10px;”>
<div style=”text-align:left; padding-top:5px;”>
<label style=”text-align:left;” for=”fscf_email1″>Email:<span style=”text-align:left;”>*</span></label>
</div>
<div style=”text-align:left;”>
<input style=”text-align:left; margin:0; width:99%; max-width:250px;” type=”text” id=”txtEmail” name=”txtEmail” value=””>
</div>
</div>
</div>
<div id=”fscf_submit_div1″ style=”text-align:left; clear:both; padding-top:15px;”>
<button type=”submit” id=”btnSubmit” onclick=”jQuery(‘#btnSubmit’).prop(‘disabled’,true); jQuery(‘#lblResult’).html(”); Subscribe();”>
<span>Submit</span>
</button>
</div>