radagast Posted April 4, 2012 Share Posted April 4, 2012 Hi I am hoping someone can help me. I have a jquery datepicker which I need to go to the next available day if the time is >16:00. I have the following script which I would like to add the above to. <script> var sd = new Date(); for(var i = 0; i < 7; i++) { if($.datepicker.noWeekends(sd)[0]) break; //found a valid day, hop out sd.setDate(sd.getDate() + 1); //move to the next day } $(function() { $( "#datepicker" ).datepicker({ beforeShowDay: $.datepicker.noWeekends, defaultDate: sd, minDate: 0, maxDate: "+1M +10D", altField: "#alternate", altFormat: "DD, d MM, yy" }); }); </script> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/260340-jquery-datepicker-go-to-next-day-on-time/ Share on other sites More sharing options...
radagast Posted April 12, 2012 Author Share Posted April 12, 2012 Ok I sorted out my problem. Bold and red below is what I added. <script> var sd = new Date(); for(var i = 0; i < 7; i++) { if($.datepicker.noWeekends(sd)[0]) break; //found a valid day, hop out sd.setDate(sd.getDate() + 1); //move to the next day } $(function() { $( "#datepicker" ).datepicker({ beforeShowDay: $.datepicker.noWeekends, defaultDate: sd, minDate: new Date().getHours() >= 16 ? 1 : 0, maxDate: "+1M +10D", altField: "#alternate", altFormat: "DD, d MM, yy" }); }); </script> Link to comment https://forums.phpfreaks.com/topic/260340-jquery-datepicker-go-to-next-day-on-time/#findComment-1336631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.