0

Could not find this online anywhere, hope you guys can help.

I have a bootstrap datepicker in my webpage (so not jQuery, it's not working for some reason). This datepicker is part of an order form. People are supposed to place an order before 10am, so they can pick it up later that day at 11.45am (or order for a few days later).

The client wants to disable the user from picking the current day WHEN it is past 10am.

So lets say you order on 1sept and it is 9am, you can select the day of pickup to be 1 september. But when you order on the 1sept and it is already past 10 am, you can only pick 2september for pickup (or 3 sept or 4 or 5 ....)

How do I set this? I have already found to disable sundays, but not this...

HTML:

<form method="POST" action="http://boutique.dev/order" accept-charset="UTF-8">  

<!-- ... -->

  <input id="datepicker" type="text" class="form-control" name="date">

<!-- ... -->          

</form>  

JS:

$(document).ready(function(){

    $( "#datepicker" ).datepicker({
        format: "dd/mm/yy",
        daysOfWeekDisabled: "0"
    });

});
nclsvh
  • 2,628
  • 5
  • 30
  • 52
  • For one, I'd use startDate, not daysOfWeekDisabled. Second, should it take the customers time into account or the store owners? Third, a conditional statement might work, load one instance when it's before 10 AM, and one after. – ravb79 Aug 30 '16 at 11:44
  • Ah great, I did not look at startDate! Should work perfectly when manually setting it depending on the time, smart thinking, will try. Also, why not use `daysOfWeekDisabled ` when there should never be orders on a Sunday. Lastly everything is local (only 1 timezone). – nclsvh Aug 30 '16 at 11:56
  • 1
    I didn't realize they didn't accept orders on Sunday; in that case you shouldn't change that. Now if you need something for the time, just check http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript – ravb79 Aug 30 '16 at 11:57

0 Answers0