Jquery Calender disable days. And wrong input

Jquery Calender disable days. And wrong input

I currently have 3 errors

I'm useing 2 calendar inputs, the first one is for pick up, and the second is for delivery, There must go 3 days from pick up and delivery. It currently works but when i change to dateFormat: 'dd-mm-yy' it makes it so i can't select days before the pick up date, but it dosen't make the 3 day "gap" where you can't pick dates 3 day after.

At the first calendar input (Pick up) You shoulnd't beable to pick today, or past days, how would i go about that?

When i insert the date into the DB, it just inserts 0000-00-00.

My code: The Jquery:


  1. $(document).ready(function(){ $(".tooweekend").hide(); $(".fromweekend").hide(); $("#txtFromDate").datepicker({ numberOfMonths: 1, dateFormat: 'dd-mm-yy', onSelect: function(selected) { var date = new Date(selected) day=date.getDate()+3; var daypicked = date.getUTCDay(); if (daypicked == '4' || daypicked == '5' || daypicked == '6' || daypicked == "") { $(".fromweekend").show(); $(".fromday").hide(); } else { $(".fromweekend").hide(); $(".fromday").show(); } newDate=date.getMonth()+1 + "/" + day + "/" + date.getFullYear(); $("#txtToDate").datepicker("option","minDate", newDate); } }); $("#txtToDate").datepicker({ numberOfMonths: 1, dateFormat: 'dd-mm-yy', onSelect: function(selected,inst) { var date = new Date(selected) var daypicked = date.getUTCDay(); if (daypicked == '4' || daypicked == '5' || daypicked == '6') { $(".tooweekend").show(); $(".tooday").hide(); }else { $(".tooweekend").hide(); $(".tooday").show(); } $("#txtFromDate").datepicker("option","maxDate", selected) } }); });
The HTML(There are diffrent times at weekends, and thats the reason why there are so many selects)

  1. <div class="fromday"> <select class="selectpicker form-control" name="dropoff_time"> <optgroup label='Tid 4 Timers interval'> <option value="08:00 - 12:00">08:00 - 12:00</option> <option value="12:00 - 16:00">12:00 - 16:00</option> <option value="16:00 - 20:00">16:00 - 20:00</option> <optgroup label='Tid 1 Time interval'> <option value="07:00 - 08:00">07:00 - 08:00</option> <option value="08:00 - 09:00">08:00 - 09:00</option> <option value="09:00 - 10:00">09:00 - 10:00</option> <option value="10:00 - 11:00">10:00 - 11:00</option> <option value="11:00 - 12:00">11:00 - 12:00</option> <option value="12:00 - 13:00">12:00 - 13:00</option> <option value="13:00 - 14:00">13:00 - 14:00</option> <option value="14:00 - 15:00">14:00 - 15:00</option> <option value="15:00 - 16:00">15:00 - 16:00</option> <option value="16:00 - 17:00">16:00 - 17:00</option> <option value="17:00 - 18:00">17:00 - 18:00</option> <option value="18:00 - 19:00">18:00 - 19:00</option> <option value="19:00 - 20:00">19:00 - 20:00</option> </select> </div> <!--Weekend--> <div class="fromweekend" > <select class="selectpicker form-control" name="dropoff_time"> <optgroup label='Tid 4 Timers interval'> <option value="09:00 - 12:00">09:00 - 12:00</option> <option value="12:00 - 17:00">12:00 - 17:00</option> <optgroup label='Tid 1 Time interval'> <option value="09:00 - 10:00">09:00 - 10:00</option> <option value="10:00 - 11:00">10:00 - 11:00</option> <option value="11:00 - 12:00">11:00 - 12:00</option> <option value="12:00 - 13:00">12:00 - 13:00</option> <option value="13:00 - 14:00">13:00 - 14:00</option> <option value="14:00 - 15:00">14:00 - 15:00</option> <option value="15:00 - 16:00">15:00 - 16:00</option> <option value="16:00 - 17:00">16:00 - 17:00</option> </select> </div> </div> <div class="col-sm-6"> <p class="orderheader">Levering</p> <input class="form-control" type="text" id="txtToDate" readonly='true' name="dropoff_date"/> <br /> <div id="timeto"> <!--Hverdag--> <div class="tooday"> <select class="selectpicker form-control" name="dropoff_time"> <optgroup label='Tid 4 Timers interval'> <option value="08:00 - 12:00">08:00 - 12:00</option> <option value="12:00 - 16:00">12:00 - 16:00</option> <option value="16:00 - 20:00">16:00 - 20:00</option> <optgroup label='Tid 1 Time interval'> <option value="07:00 - 08:00">07:00 - 08:00</option> <option value="08:00 - 09:00">08:00 - 09:00</option> <option value="09:00 - 10:00">09:00 - 10:00</option> <option value="10:00 - 11:00">10:00 - 11:00</option> <option value="11:00 - 12:00">11:00 - 12:00</option> <option value="12:00 - 13:00">12:00 - 13:00</option> <option value="13:00 - 14:00">13:00 - 14:00</option> <option value="14:00 - 15:00">14:00 - 15:00</option> <option value="15:00 - 16:00">15:00 - 16:00</option> <option value="16:00 - 17:00">16:00 - 17:00</option> <option value="17:00 - 18:00">17:00 - 18:00</option> <option value="18:00 - 19:00">18:00 - 19:00</option> <option value="19:00 - 20:00">19:00 - 20:00</option> </select> </div> <!--Weekend--> <div class="tooweekend" > <select class="selectpicker form-control" name="dropoff_time"> <optgroup label='Tid 4 Timers interval'> <option value="09:00 - 12:00">09:00 - 12:00</option> <option value="12:00 - 17:00">12:00 - 17:00</option> <optgroup label='Tid 1 Time interval'> <option value="09:00 - 10:00">09:00 - 10:00</option> <option value="10:00 - 11:00">10:00 - 11:00</option> <option value="11:00 - 12:00">11:00 - 12:00</option> <option value="12:00 - 13:00">12:00 - 13:00</option> <option value="13:00 - 14:00">13:00 - 14:00</option> <option value="14:00 - 15:00">14:00 - 15:00</option> <option value="15:00 - 16:00">15:00 - 16:00</option> <option value="16:00 - 17:00">16:00 - 17:00</option> </select> </div> </div> </div> </div>