AnsweredAssumed Answered

Manipulate form via API without** embedding the form on a marketo landing page

Question asked by Anthony Dykstra on Jan 10, 2018
Latest reply on Jan 11, 2018 by Sanford Whiteman

I customized the datepicker on one of our forms so that I could remove weekends and holidays using jQuery and MktoForms2 API. In order to achieve this, I had to embed the form into a marketo landing page template. The downside is when I create a landing page with this template, the landing page editor doesn't recognize that there is a form on the page which ultimately will cause us to jump through a few extra hoops from a reporting standpoint.

 

Is it possible to accomplish the same customization with a form that has been added to a page via the <div class="mktoForm"> container to bypass the shortcomings of embedding?

 

Sanford Whiteman - Perhaps you might have some valuable insight?

 

Here's the code I used on the template:

<div>

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

<form id="mktoForm_1687"></form>

<script>

MktoForms2.loadForm("//app-ab01.marketo.com", "XXX-XXX-XXX", 1687);

 

 

var disabledDates = ["01-01-2018","02-19-2018","05-28-2018","07-04-2018","09-03-2018","11-22-2018","12-25-2018"];

 

 

MktoForms2.whenReady(function (form) {

 

$("#callDate").datepicker({

beforeShowDay: function(date) {

var string = jQuery.datepicker.formatDate('mm-dd-yy', date);

return [ disabledDates.indexOf(string) == -1 ]

},

minDate: 0,

maxDate: new Date(2018, 11, 31)

});

});

</script>

</div>

Outcomes