Skip to main content
March 14, 2013
해결됨

Insert Email Address into JavaScript on Form Submission

  • March 14, 2013
  • 1 답변
  • 970 조회
We're looking to run a peice of JavaScript on one of our form submission confirmation pages.  We want to take some data submitted by the customer on the form (e.g. email address) and insert it into the JavaScript for processing.  Is there a way to do this?
이 주제는 답변이 닫혔습니다.
최고의 답변:
Yes, we have a java script that validates the domain of the email address that is submitted in a form.  Below is the script we are running with an abridged invalid domain list.  Hope this helps.

<style type="text/css">
span.mktFormMsg {
display:block !important;
left:5px !important;
position: relative !important;
}
</style>

<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 = ["@123mail.org","@aol.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>

1 답변

답변
March 14, 2013
Yes, we have a java script that validates the domain of the email address that is submitted in a form.  Below is the script we are running with an abridged invalid domain list.  Hope this helps.

<style type="text/css">
span.mktFormMsg {
display:block !important;
left:5px !important;
position: relative !important;
}
</style>

<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 = ["@123mail.org","@aol.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>