Saturdays Only In .JS Datepicker
I'm working with a pre-integrated .js datepicker and need to ensure only Saturdays are selectable. My code in it's current form: (function($){ 'use strict'; $.fn.gdlr_datepick
Solution 1:
Quoting the docs on beforeShowDay
param:
A function that takes a date as a parameter and must return an array with:
[0]: true/false indicating whether or not this date is selectable [1]: a CSS class name to add to the date`s cell or "" for the default presentation [2]: an optional popup tooltip for this date
It's easy to guess the solution: just change beforeShowDay
function so that it checks the day of week of selected date when setting the first element of the returned array:
return [date.getDay() === 6, /* the rest remains the same */];
Demo.
Solution 2:
Did you try using the getDay()?
$(function() {
$("#datepicker").datepicker({
beforeShowDay: function(date) {
if(date.getDay() == 6) {
return [true];
} else {
return [false];
}
}
});
});
Post a Comment for "Saturdays Only In .JS Datepicker"