I am using the Datepicker via bootstrap JavaScript. I have this code:
<div class="col-sm-4">
@Html.TextBoxFor(m => m.Trust.EstablishmentDate, "{0:dd-MM-yyyy}", new { id = "establishmentDate", @readonly = "readonly", @class = "datefield form-control" })
@Html.ValidationMessageFor(m => m.Trust.EstablishmentDate, null, new { @class = "help-block" })
</div>
$(document).ready(function () {
$("#establishmentDate").datepicker({
changeMonth: true,
changeYear: true,
format: 'dd-mm-yyyy',
});
});
The above code worked fine while publishing it in IE, displaying and recognizing the date in the required dd-mm-yyyy format from date picker.
But the same code is not working as expected in the Edge browser where the below error is getting prompted: The required field must be a date.
It's recognizing the format as mm-dd-yyyy and hence the above error appears when it finds the month as invalid for the cases like 22-06-22, where as for cases like 02-06-22, its recognizes as 6th Feb.