On an ASP.NET page, I have a pair of CalendarExtender
(AJAX Control Toolkit for ASP.NET 4.0) controls on a page acting as a date range. What I want to do is, after the user has selected the value for TextCheckInDate
, populate TextCheckOutDate
with TextCheckInDate+ 1
if TextCheckOutDate
is empty.
Regrettably, my jQuery skills aren't yet where I'd like them to be. I know that I have to create a jQuery function that's fired when TextCheckInDate
changes, I need to be able to read both textboxes, perform basic date arithmetic and write to the second textbox. The implementation eludes me. Thanks to this post, I know to use date.js for my date arithmetic, included below...
What I have so far:
$("input[id$='TextCheckInDate']").keyup
(function (e) {
checkCheckOutDate( $("#TextCheckInDate").val() );
}
);
function checkCheckOutDate(checkInDate) {
var startDate = Date.parse(checkInDate);
if ($("#TextCheckOutDate").val() == "") {
$("#TextCheckOutDate").val((1).days().after(startDate));
}
}