Jump to content

jquery datepicker - go to next day on time


radagast

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.