jQuery UI Datepicker Testing

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.9.0-rc.1/jquery-ui.min.js"></script>
<p>Click in first date field and then in 2nd date field.</p>
<p>
    Dates - 
    1st: <input type="text" id="date1" /> 
    2nd: <input type="text" id="date2" />
</p>

JavaScript

$("#date1").datepicker();
$("#date2").datepicker();

$("#date2").on("change", function () {
    var theDate = new Date($("#date2").val());
    theDate.setDate(theDate.getDate() + 1);
    $("#date2").datepicker("setDate", theDate);
});