0

I have written code in jsfiddle.net/udgeet/VUb5r/

I have to disable the previously selected date

udgeet patel
  • 439
  • 1
  • 7
  • 23
  • 1
    http://stackoverflow.com/questions/1116778/jquery-datepicker-multiple-instances-and-disable-previously-selected-dates – nikinup Nov 30 '12 at 08:47

1 Answers1

0

You can use datePicker's beforeShowDay option to specify which dates you want to enable or disable.

Then it's just a case of writing a functions to

a) get the dates from the select into an array:

function daysToDisable() {
    var dates = [];
    for (i = 0; i < $('#inputdates option').length; i++) {
        dates[i] = new Date($('#inputdates option').eq(i).val()).toString();
    }
    return dates;
}

and b) return true or false if the current date is in the array

function disableDates(date) {
    var days = daysToDisable();
    for (i = 0; i < days.length; i++) {  
        if ($.inArray(date.toString(), days) != -1) {
            return [false];
        }  
    }
    return [true];  
}

http://jsfiddle.net/vy562/1/

Elliott
  • 2,669
  • 2
  • 23
  • 33