@model HelloWorldMvcApp.SampleViewModel
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
.field-validation-error {
<div class="col-md-6 col-md-offset-3">
@using (Html.BeginForm())
<div class="col-md-6 no-padding">
@Html.LabelFor(model => model.EnquiryDateFormatted, htmlAttributes: new { @class = "control-label lblrequired" })
@Html.TextBoxFor(model => model.EnquiryDateFormatted, "{0:dd-MMM-yyyy}", new { @class = "form-control newinput datepicker", @autocomplete = "off",@id="enquiryDateID" })
@Html.ValidationMessageFor(model => model.EnquiryDateFormatted, "", new { @class = "text-danger" })
<div class="alert alert-warning fade">
<img src="http://entechprod.blob.core.windows.net/dotnetfiddle/morpheus.jpg" style="max-width:100%;"/><br/><br/>
<strong><span class="alert-content"></span></strong>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/css/bootstrap-datepicker.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/4.0/jquery.validate.unobtrusive.min.js"></script>
<script type="text/javascript">
$('input.datepicker').datepicker({
startDate: getCurrentFiscalYear($('input.datepicker').val()).sDate,
endDate: getCurrentFiscalYear($('input.datepicker').val()).eDate,
console.log($('input.datepicker').val());
console.log(getCurrentFiscalYear($('input.datepicker').val()));
function getCurrentFiscalYear(date) {
var docDate = new Date(date);
var month = docDate.getMonth();
nextYear = (docDate.getFullYear() + 1).toString();
dates.sDate = new Date(docDate.getFullYear(), 3, 1);
dates.eDate = new Date(dates.sDate.getFullYear() + 1, dates.sDate.getMonth() - 1, 31)
// dates.sDate = "01-Apr-" + docDate.getFullYear().toString();
// dates.eDate = "31-Mar-" + (docDate.getFullYear() + 1).toString();
console.log(dates.sDate);
console.log(dates.eDate);
dates.sDate = new Date(docDate.getFullYear() - 1, 3, 1);
dates.eDate = new Date(docDate.getFullYear(), dates.sDate.getMonth() - 1, 31);
// dates.sDate = "01-Apr-" + (docDate.getFullYear() - 1).toString();
// dates.eDate = "31-Mar-" + nextYear.toString();
console.log(dates.sDate);
console.log(dates.eDate);