Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have the following in the code first

C#
[Column(TypeName = "date")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime? starting_date { get; set; }


I have the following in frontend

HTML
<label>Starting Date:</label> @Html.TextBoxFor(a => a.starting_date)
@Html.ValidationMessageFor(a => a.starting_date)<br />


I have the following in script

JavaScript
$(document).ready(function () {
    $('#starting_date').datepicker({ dateFormat: "dd/mm/yy" });
});


What I have tried:

what shall I do to avoid different date formats because the validation detecting the browser date format which I can't expect or detect it, is it applicable to use dd/mm/yy format in all browsers with different date formats, or detect the current date format to change datepicker format
Posted
Updated 5-Aug-18 14:28pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900