Inside my mvc razor form I have inputbox for datetime. I'm using datetime picker plugin which allows me to enter date and time as well. I initialized this plugin script to format datetime as
$('.dateTime').datetimepicker({
timeFormat: "HH:mm:ss",
dateFormat: 'dd.mm.yy',
});
Datetime property inside my model (which I use in razor form) has dataannotation to format date as
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy HH:mm:ss}")]
public DateTime MyDateTime{ get; set; }
Inside form when I select desired date and time my text box is filled with values like
28.03.2015 09:12:00
As far as I can see this datetime format suits my model datetime format but I'm getting form js validation error
The field MyDate must be a date.
Update: Inside form I'm already getting datetime in format which I need
28.03.2015 09:12:00
and if I remove dataformat annotation from my model properties than I cannot process the form back to controller it brings up datetime window to enter datetime again?
Does anyone has solution?