I want to create a simple ASP.Net form, that will get birth dates. I have a model with this property:
[DataType(DataType.Date)]
public DateTime? BirthDate{ get; set; }
and in my view (is using the datepicker):
@Html.LabelFor(model => model.BirthDate)
@Html.TextBoxFor(model => model.BirthDate, new { @class = "form-control date-picker" })
@Html.ValidationMessageFor(model => model.BirthDate, "", new { @class = "text-danger" })
The only one setting on my javascript datepicker is:
format: 'L'
because I want show dates without times.
Now, I can't save, because of the validation error:
The value '12/23/2000' is not valid for BirthDate.
Now, I KNOW, its a globalization error... I need set culture in <globalization>
element in web.config, etc...
But, have you noticed I set no formats (except the datepicker format "L")? I want that form get birthdates from people in any country, no a specific culture/format etc.
Is this possible? How can I do it?
Edit:
- which date picker are u using?
The JQuery one, but this is not a requeriment, I can change to any datepicker that can easily handle different save formats "yyyy-mm-dd" and display format. - Which locale your server is located and which format do you prefer to work within your MVC code and to persist in database?
I dont know where my customer will host the site, its AWS... I prefer work with en-us.