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 Quote Link to comment 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. Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.