Forms 2.0 Not Working with HTML

Anonymous
Not applicable

Forms 2.0 Not Working with HTML

Hi everyone, 

I'm using a new form I created with the 2.0 editor, and on the majority of our submission pages we have HTML that blocks the use of public service email domains, such as Gmail and Yahoo. The same HTML continues to work with older forms, but isn't working with the new 2.0 form. Would anyone have any input on the issue?
Tags (1)
3 REPLIES 3
Justin_Cooperm2
Level 10

Re: Forms 2.0 Not Working with HTML

Are you embedding the form on your own page or using a langing page? Also, what is the HTML that is preventing input of certain domains? Is it using the pattern attribute?

Anonymous
Not applicable

Re: Forms 2.0 Not Working with HTML

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>
Anonymous
Not applicable

Re: Forms 2.0 Not Working with HTML

Hey Alec,

Please refer to developers.marketo.com for documentation on how to do specifically this using the new Forms 2.0 JS API.

Example #9 is what you should leverage to get this working in the new editor.

Thanks,

Jason