I'm developing an asp.net mvc application, in which I'm trying to get a Date value using a datepicker, I've been struggling a lot to find an appropriate solution but no success, what I want it to accept: dd/mm/yyyy but after picking the date, the datepicker take always this format: mm/dd/yyyy
Screenshot
The problem that the ModelState will be not valid the day's value is bigger als 12 (debugger read that as month).
View Code :
<input id="datepicker" name="Date" type="text" value="dd/mm/yyyy" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'dd/mm/yyyy';}" required="">
<script>
$(function ()
{
$("#datepicker").datepicker({ minDate: 0 });
});
</script>
Model code :
[Required]
public DateTime Date { get; set; }
dd/MM/yyyy
format if that is what you expect the users to post the format inglobalization culture="[culture with dd/MM/yyyy format]"
too.