6 Replies Latest reply on Dec 11, 2015 7:07 AM by 649c33a7ea3061e6bdbc7f93bbd45fa38c8d4ca8

    custom JS in landing page forms

      Our marketing department asked me to limit the number of checkboxes allowed to be chosen to 3. I can make it work from my development server, but when inserted into the template, it fails. I'm missing something very simple... I'm certain! Here is the code with a few parameters changed. Any help is appreciated! destinationmap is the name of all of the checkboxes.

       

      <script src="//app-ab07.marketo.com/js/forms2/js/forms2.min.js"></script>

      <form id="mktoForm_####"></form>

      <script>MktoForms2.loadForm("//app-ab07.marketo.com", "###-###-###", ####, function(form) {

              // From here we have access to the form object and can call its methods

             var limit = 3;

             form.onValidate(function() {

             // Get the values

             var vals = form.vals();                              

             var kount = vals.destinationmap.length;

             if(kount > 3){

                  alert('You may only choose up to three countries for which to receive a map.');

                  form.submittable(false);             

             }     

        });      

      });

      </script>