I have a property named StartDate
in my model. I have used timepicker
add-on to jquery.ui
plugin from here. It is working fine, but problem is that I'm getting validation error message. How can I change validation so that it passes for date-time.
The model is:
public class DateTimePickerTest : EntityBase
{
[DataType(DataType.DateTime)]
[DisplayName("Start Date")]
public DateTime StartDate { get; set; }
[DataType(DataType.DateTime)]
[DisplayName("End Date")]
public DateTime EndDate { get; set; }
}
I'm mostly following directions given here on MSDN by Rick Anderson.
Saved by this answer.
I have used DisplayFormat
attribute with ApplyFormatInEditMode
property set to true
:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.mm.yy}")]