$(function() {
var year = (new Date).getFullYear();
$(".start_date").datepicker({
showOn: "button",
buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
buttonText: "Select date",
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: true,
minDate: 0,
//maxDate : "+1Y",
maxDate: new Date(year, 03, 31),
// maxDate: "+3m"
showAnim: "clip",
numberOfMonths: 1,
onSelect: function(dt, dp) {
var selected = $.datepicker.parseDate("dd-mm-yy", dt);
var yy = selected.getFullYear();
var mm = selected.getMonth();
var dd = selected.getDate()
var nextYear = $.datepicker.parseDate("dd-mm-yy", "31-03-" + (yy + 1));
$(".end_date").datepicker("option", "maxDate", nextYear);
}
});
$(".end_date").datepicker({
showOn: "button",
buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
buttonText: "Select date",
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: true,
minDate: 0,
//maxDate : "+1Y",
maxDate: new Date(year, 03, 31),
showAnim: "clip"
//numberOfMonths: 2
});
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<div class="form-group">
<label>Start Date</label>
<input type="text" name="start_date" placeholder="Start Date" id="start_date" class="start_date form-control">
</div>
<div class="form-group">
<label>End Date</label>
<input type="text" name="end_date" id="end_date" placeholder="End Date" class="end_date form-control">
</div>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>