Rose Rose - 10 months ago 31
jQuery Question

Display a datepicker with dates lies between two given dates in jquery

I have a

start date = '02/08/2016'
end date = '20/08/2016'
. Now I need a result in
such that, dates from

should be displayed and all other past and later dates should be disabled.

How can I achieve it?


this how you can achieve the dates between two dates. hope this may help you, as said by @cfs on this page, you can disable previous days by this script:

$(function() {
    $( "#datepicker,#datepicker1" ).datepicker({
        minDate:new Date()

var start = $("#from").datepicker("getDate"),
    end = $("#to").datepicker("getDate"),
    currentDate = new Date(start.getTime()),
    between = []

while (currentDate <= end) {
    between.push(new Date(currentDate));
    currentDate.setDate(currentDate.getDate() + 1);

here's the fiddle to see working demo