I found reference #1 (below) of how to set defaults for a date field picker. For some reason you have to set the default of beforeShow to a function which then sets the option of beforeShowDay.
Not sure what the redundancy is here, but it does work.
So I came up with this code:
function checkField(input) { $(input).datepicker("option", {beforeShowDay: function(d){ var ds = d.toDateString(); return [ds==getPreviousMonday() || ds==getFutureMondayOf(1) || ds==getFutureMondayOf(2) || ds==getFutureMondayOf(3) || ds==getFutureMondayOf(4) ,""];} }); } $.datepicker.setDefaults({beforeShow: checkField});
It works! The problem with this code is that $.datepicker is not class dependent, which means it will seek out and apply to any date field it finds. That is not going to work in many cases. So I found reference #2 (below) where it was stated you need to use an option instead of setDefaults if you want to work by class name.
So this is odd, now I am switching back to the option method to call the beforeShow so I can call the beforeShowDay
I switched the last line of my code to this:
$('.myDateField').datepicker("option", {beforeShow: checkField});
Nothing happens.
I tried just setting my beforeShowDay this way as well instead of creating a function called checkField, but nothing happens there either.
I exclusively use classes to make sure I am working with the right field(s). How would I set defaults on a date by class name?
Reference #1 https://answers.laserfiche.com/questions/173587/Restricting-Date-Picker#174123
Reference #2 https://answers.laserfiche.com/questions/182596/Forms-Calendar--Restrict-to-specific-list-of-dates#182648