1 Reply Latest reply on Feb 20, 2015 10:57 PM by Sanford Whiteman

    Embedded form 2.0 - need it to call an exteranl script on submit

      Looking for the JS guru's out there.  I have the standard embed code for a Forms 2.0 script on a webpage, but I have a rather long validation script to look for fake/temp. email addresses.  I need the embed script to also call to my external script when the "submit" button is clicked.

      Any ideas?
        • Re: Embedded form 2.0 - need it to call an exteranl script on submit
          Sanford Whiteman
          Use the onValidate handler as in the Forms 2.0 API docs.

          <script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
          <form id="mktoForm_96"></form>
          <script>MktoForms2.loadForm("//app-zz01.marketo.com", "AAA-BBB-CCC, 96,
              function(form) {   
            form.onValidate(function(){
              // I'm checking a sample condition - this is where you'd call your external validation script
              if(form.vals().LastName != "Go For It"){
                //prevent form submission
                console.log('setting unsubmittable (submit step will not run) - try again');
                form.submittable(false);
              }else{
                //enable submission for those who met the criteria.
                console.log('setting submittable (submit step will run next)');
                form.submittable(true);
              }
              })
              });
          </script>

          Running here.