1.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$("#start_date").datepicker({
dateFormat: 'yy-mm-dd',
showOn: 'button',
buttonText: "start",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: 'c-1:c+10',
minDate: '0d'
});
$("#end_date").datepicker({
dateFormat: 'yy-mm-dd',
showOn: 'button',
buttonText: "start",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: 'c-1:c+10',
minDate: '0d',
beforeShow: function() {
var startDate = $("#start_date").datepicker('getDate');
//if a date was selected else do nothing
if (startDate != null) {
startDate.setMonth(startDate.getMonth());
$(this).datepicker('option', 'minDate', startDate);
}
}
});
});
</script>
</head>
<body>
<p>start Date: <input type="text" id="start_date"></p>
<p>end Date: <input type="text" id="end_date"></p>
</body>
</html>
2.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$("#from").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function(selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);
}
});
$("#to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function(selectedDate) {
$("#from").datepicker("option", "maxDate", selectedDate);
}
});
});
</script>
</head>
<body>
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
</body>
</html>