I have two Jquery date pickers, in which a range of dates can be selected.
I have implemented certain restrictions like, the date of textbox2 should be always greate
I added a function "validateDateRange" to your code to illustrate the logic required to complete this task. Please note that the intention of the function I added is to simply pop up an alert if the condition you described occurs. From here you should be able to do whatever you like. Let us know if you have more questions or were looking for something else.
Here are my updates
function validateDateRange() {
var txtStartDate = $("#start_date");
var txtEndDate = $("#end_date");
var startDate;
var endDate;
var tempDate;
if (txtStartDate.val() == "")
return false;
if (txtEndDate.val() == "")
return false;
startDate = new Date(txtStartDate.val());
endDate = new Date(txtEndDate.val());
for (i = 0; i < unavailableDates.length; i++) {
var temp = unavailableDates[i].split("-");
tempDate = new Date(temp[2], temp[1]-1, temp[0]);
if (startDate < tempDate && endDate > tempDate) {
alert("Invalid Date Range");
return false;
}
}
}