I'm using a landing page, and the HTML is below. It's strange because it still works perfectly fine for our other submission pages. If you have any suggestions on anything that would work better I'm open to it.
<!-- Validate the email address field in forms for a non-public domain -->
<script type="text/javascript" src="/js/public/jquery-latest.min.js" language="JavaScript"></script>
<script type="text/javascript">
// set no conflict mode for jquery
var $jQ = jQuery.noConflict();
//edit this list with the domains you want to block
var invalidDomains = ["@yahoo.com", "@gmail.com", "@hotmail.com"];
function formSubmit(elt) {
// run the custom validation. If it succeeds, run the Marketo validation
if (!isEmailGood()) {
Mkto.setError($jQ("#Email ~ span").prev()[0],"Please enter a business address, not one from a public service");
return false;
} else {
Mkto.clearError($jQ("#Email ~ span").prev()[0]);
}
return Mkto.formSubmit(elt);
}
function isEmailGood() {
for(i=0; i < invalidDomains.length; i++) {
if ( $jQ("#Email[value*=" + invalidDomains[i] + "]").length > 0) {
return false;
}
}
return true;
}
</script>