Reputation: 9
I want to check that the expiration date is greater than another date.
[DisplayFormat(DataFormatString = "0:yyyy/MM/dd", ApplyFormatInEditMode = true)]
public DateTime? Date { get; set; }
[DisplayFormat(DataFormatString = "0:yyyy/MM/dd", ApplyFormatInEditMode = true)]
public DateTime? Expiration { get; set; }
How do I do this?
Upvotes: 0
Views: 121
Reputation: 56
for example
DateTime date = DateTime.Now;
DateTime expiration = DateTime.Now.AddDays(3);
if (expiration > date)
you can compare dates like this
Upvotes: 1
Reputation: 844
You need to create a custom validator to check your different dates using ValidationAttribute
.
Take a look of this link.
Upvotes: 1