3

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; }
}

Following is the error message

I'm mostly following directions given here on MSDN by Rick Anderson.

TheVillageIdiot
  • 40,053
  • 20
  • 133
  • 188

1 Answers1

4

Saved by this answer.

I have used DisplayFormat attribute with ApplyFormatInEditMode property set to true:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.mm.yy}")]
Community
  • 1
  • 1
TheVillageIdiot
  • 40,053
  • 20
  • 133
  • 188