I have a problem with EditorFor(DateTime) function. I have a model defined like this:
[MetadataType(typeof(MessageSearchDTO_Validation))]
public class MessageSearchDTO
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public class MessageSearchDTO_Validation
{
[DisplayName("Od")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm}")]
[Required(ErrorMessage = ErrorMessages.FieldRequired)]
public DateTime StartDate { get; set; }
[DisplayName("Do")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm}")]
[CustomValidation(typeof(MessageSearchDTO_Validation), "EndDate_CustomValidator")]
[Required(ErrorMessage = ErrorMessages.FieldRequired)]
public DateTime EndDate { get; set; }
}
The problem is that I want a full date with time editor. But it works only in Chrome. In FF/IE I'm getting this javascript validation error. If I set the value of "10/23/2013 12:00:00 AM" it works fine. But how do I force the datetime format I desire?
I even tried to implement custom binder, it didn't work because this is client side error...