zimmo Posted October 7, 2010 Share Posted October 7, 2010 I am trying to extend my plug in by restricting the sunday from the calendar. I am not sure how to do this with my existing code. here is the code which is currently not working: <script type="text/javascript"> $(function() { // Tabs $('#datepicker1').datepicker({ beforeShowDay: function(date) { return [(date.getDay() > 1), ""]; } minDate: 0, maxDate: "+12M +0D", dateFormat: 'dd-mm-yy' }); }); </script> Can anyone see anything obvious?? Thanks Barry Link to comment https://forums.phpfreaks.com/topic/215317-jquery-datepicker-problem/ Share on other sites More sharing options...
Adam Posted October 7, 2010 Share Posted October 7, 2010 From what I can tell, the jQuery datepicker widget doesn't have an option that'll let you do this. Link to comment https://forums.phpfreaks.com/topic/215317-jquery-datepicker-problem/#findComment-1119754 Share on other sites More sharing options...
zimmo Posted October 7, 2010 Author Share Posted October 7, 2010 I have been searching google and have found some code where people have managed to do this. The code below works great now, I can specify holidays etc.. that are closed and also sundays being closed. I need to extend this, (not a javascript expert) so that I can specify mothers day and valentines day for delivery as well. Can anyone help me do this????? I need to change this code to allow for specific days that they are OPEN. It only allows closed days. <script type="text/javascript"> $(document).ready(function(){ $("#datepicker").datepicker({ beforeShowDay: nonWorkingDates, numberOfMonths: 1, minDate: '0', maxDate: '+12M', firstDay: 1 }); function nonWorkingDates(date){ var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6; var closedDates = [[7, 29, 2009], [8, 25, 2010]]; var closedDays = [[sunday]]; for (var i = 0; i < closedDays.length; i++) { if (day == closedDays[i][0]) { return [false]; } } for (i = 0; i < closedDates.length; i++) { if (date.getMonth() == closedDates[i][0] - 1 && date.getDate() == closedDates[i][1] && date.getFullYear() == closedDates[i][2]) { return [false]; } } return [true]; } }); </script> Link to comment https://forums.phpfreaks.com/topic/215317-jquery-datepicker-problem/#findComment-1119773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.