Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  119] [ 1]  / answers: 1 / hits: 20522  / 11 Years ago, thu, february 27, 2014, 12:00:00

I'm making a holiday booking application and obviously you don't need to book off holidays that are already given to you, so I need to know how I can disable, Christmas, for example from the date picker every year without me having to change the code every year.



This is my jQuery UI date picker code so far:



<script>
$(function() {
$(#from).datepicker({
beforeShowDay: $.datepicker.noWeekends,
defaultDate: today,
changeMonth: true,
numberOfMonths: 1,
minDate: today,
dateFormat: dd/mm/yy,
onClose: function(selectedDate) {
$( #to ).datepicker(option, minDate, selectedDate);
}
});
$(#to).datepicker({
beforeShowDay: $.datepicker.noWeekends,
defaultDate: today,
changeMonth: true,
numberOfMonths: 1,
minDate: today,
dateFormat: dd/mm/yy,
onClose: function(selectedDate) {
$(#from).datepicker(option, maxDate, selectedDate);
}
});
});
</script>

More From » jquery

 Answers
21

you can exclude the dates like



var holidays = [2014-02-27,2014-02-01];
$( #from ).datepicker({
beforeShowDay: function(date){
var datestring = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ holidays.indexOf(datestring) == -1 ]
}
});


you can provide more dates to the holidays array


[#72272] Wednesday, February 26, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sonja

Total Points: 541
Total Questions: 113
Total Answers: 114

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
sonja questions
Mon, Nov 30, 20, 00:00, 4 Years ago
Sun, Oct 11, 20, 00:00, 4 Years ago
Thu, May 21, 20, 00:00, 4 Years ago
Sun, Nov 10, 19, 00:00, 5 Years ago
Mon, Aug 26, 19, 00:00, 5 Years ago
;