My MVC datepicker field is giving me the year twice. So today's date appears like this:
09/16/20152015
I'm wondering what's going wrong. Here's a section from my create view:
<div class="form-group">
@Html.LabelFor(model => model.BirthDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.BirthDate)
@Html.ValidationMessageFor(model => model.BirthDate)
</div>
</div>
I have a custom editor:
@model DateTime?
@{
var value = "";
if (Model.HasValue) {
value = String.Format("{0:d}", Model.Value.ToString());
}
}
@Html.TextBox("", value, new { @class = "datepicker", type = "text" })
My Javascript Script.js file has this:
$(document).ready(function () {
$(".datepicker").datepicker({
dateFormat: "mm/dd/yyyy",
autoclose: true
});
});
Any ideas what I'm doing wrong?