I am using Jquery UI date picker in my asp.net MVC app. All works fine in IE but in Chrome the default date picker is also visible, when I use JQuery UI it doesn't add the date to the box.
I have several options that are on here as possible solutions but nothing works.
The ViewModel is:
[Required]
[Display(Name = "Date of Birth")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public DateTime DateOfBirth { get; set; }
The View is:
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-1">
@Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "form-control", placeholder = "01/12/80" } })
@Html.ValidationMessageFor(model => model.DateOfBirth, "", new { @class = "text-danger" })
</div>
</div>
</div>
The script for the date picker is :
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
<script type="text/javascript">
$("#DateOfBirth").datepicker({
format: "yyyy/MM/dd",
startDate: "-120y",
endDate: "-10y",
startView: 2,
calendarWeeks: true,
defaultViewDate: { year: 1975, month: 01, day: 01 }
});
</script>
}
I can't be the only one who needs to solve this issue and hopefully it already has been. Thanks