Custom date selection validation within a date picker field type

Anonymous
Not applicable

Custom date selection validation within a date picker field type

Is there a way to customise the dates that are available to be selected from the Date Picker field type within a form?

For example, can it be set to allow business day selections only? Or invalidate the selection of older dates? Or invalidate dates within a range?

Thanks in advance!

1 REPLY 1
Anonymous
Not applicable

Re: Custom date selection validation within a date picker field type

Hi Michael,

I've made a work around with this custom available dates for selection, turns out that Marketo is using the jQuery UI datepicker element, so you can add extra things using it's API.

http://api.jqueryui.com/datepicker/

The trick is adding custom JS code in the landing page for altering the datepicker properties, for example I used the following code:

MktoForms2.$('.mktoDateField').datepicker( "option", "maxDate", new Date('2016-12-01'));

MktoForms2.$('.mktoDateField').datepicker( "option", "minDate", new Date('2016-12-12'));

hope it helps.