model-validation

MVC model validation for date

谁都会走 提交于 2019-11-26 08:34:41
问题 Is there any default validation for MVC 5 where I can set min and max value of date? In my model i want date validation public class MyClass { [Required(ErrorMessage=\"Start date and time cannot be empty\")] //validate:Must be greater than current date [DataType(DataType.DateTime)] public DateTime StartDateTime { get; set; } [Required(ErrorMessage=\"End date and time cannot be empty\")] //validate:must be greater than StartDate [DataType(DataType.DateTime)] public DateTime EndDateTime { get;