Block Form Submission from Specific Email Account

Highlighted
Anonymous
Not applicable

Block Form Submission from Specific Email Account

Hi -- We have a select few companies who fill out our contact us form with the same message on a regular basis, and we would like to block these companies from doing so. Is there a way to do this? Are we able to either send them an error message or not record their submission? Thanks, Stephanie

Tags (2)
4 REPLIES 4
Highlighted

Re: Block Form Submission from Specific Email Account

Hi Stephanie Bradbury​,

This can easily be done with a few lines of Javascript to be added, using the forms 2.0 API. Forms 2.0 » Marketo Developers

-Greg

Highlighted
Anonymous
Not applicable

Re: Block Form Submission from Specific Email Account

That's can be done using Forms 2.0.

Here a snippet of JS that can be used to solve your problem:

<script src="//app-abj.marketo.com/js/forms2/js/forms2.min.js"></script> <form id="mktoForm_xxxx"></form>

<script>MktoForms2.loadForm("//app-abj.marketo.com", "xxx-xxx-xxx", xxxx);</script>

<script>

(function (){

  var invalidCompanies = ["abc"];

  MktoForms2.whenReady(function (form){

    form.onValidate(function(){

      var company = form.vals().CompanyName;

      if(company){

        if(!isGoodBusiness(company)) {

          form.submitable(false);

          var companyElem = form.getFormElem().find("#CompanyName");

          form.showErrorMessage("Sorry, this company does not work.", companyElem);

        }else{

          form.submitable(true);

        }

      }

    });

  });

  function isGoodBusiness(testCompany) {

    for(var i=0; i < invalidCompanies.length; i++) {

      var company = invalidCompanies[i];

      if (testCompany.indexOf(company) != -1) {

        return false;

      }

    }

    return true;

  }

})();

</script>

Highlighted
Level 10 - Community Moderator

Re: Block Form Submission from Specific Email Account

That'll catch 'Zabco', though. You probably want an exact match.

(Also, I don't know if the OP meant literally the Company field or the email domain.)

Highlighted
Anonymous
Not applicable

Re: Block Form Submission from Specific Email Account

Sanford,

just an example. It needs to be tested and changed accordingly with the appropriated fields.