I have a ViewModel for my MVC4 Prject containing two DateTime properties:
[Required]
[DataType(DataType.Date)]
public DateTime RentDate { get; set; }
[Required]
It looks like you're using DataAnnotations so another alternative is to implement IValidatableObject
in the view model:
public IEnumerable Validate(ValidationContext validationContext)
{
if (this.RentDate > this.ReturnDate)
{
yield return new ValidationResult("Rent date must be prior to return date", new[] { "RentDate" });
}
}