AIM: TO only allow users to select sunday on the datpicker calendar.
Currently I have it almost done, except for some reason every other day except Sunday works. When I use 7 for Sunday in the code below the entire calendar is unclickable, any other day works perfect.
$(document).ready(function() {
$("#datepicker2").datepicker({
autoSize: true, // automatically resize the input field
altFormat: 'yy-mm-dd', // Date Format used
firstDay: 1, // Start with Monday
beforeShowDay: function(date)
{ return [date.getDay() == 7,''];}}); // Allow only one day a week
});
Question: How can I only allow Sunday selection?
AIM: TO only allow users to select sunday on the datpicker calendar.
Currently I have it almost done, except for some reason every other day except Sunday works. When I use 7 for Sunday in the code below the entire calendar is unclickable, any other day works perfect.
$(document).ready(function() {
$("#datepicker2").datepicker({
autoSize: true, // automatically resize the input field
altFormat: 'yy-mm-dd', // Date Format used
firstDay: 1, // Start with Monday
beforeShowDay: function(date)
{ return [date.getDay() == 7,''];}}); // Allow only one day a week
});
Question: How can I only allow Sunday selection?
Share Improve this question asked Feb 15, 2013 at 17:56 RhysRhys 2,8779 gold badges48 silver badges70 bronze badges1 Answer
Reset to default 9Date.getDay()
returns a value in the range 0-6
, not 1-7
.
beforeShowDay: function(date) {
return [date.getDay() === 0,''];
}