Reputation: 187
I try to compare two TimeSpan fields. Code below doesn't works. Also, I remove [DataType(DataType.Time)] and try without any success.
[Required(ErrorMessage = "Required start time")]
[DataType(DataType.Time)]
[Compare("EndTime", ErrorMessage = "Početak i kraj smjene moraju biti različiti.")]
public System.TimeSpan StartTime { get; set; }
[Required(ErrorMessage = "Required end time")]
[DataType(DataType.Time)]
public System.TimeSpan EndTime { get; set; }
How to compare two TimeSpan fields?
Upvotes: 0
Views: 730
Reputation: 1185
Check out FluentValidation, I was shown this and it works great.
http://fluentvalidation.codeplex.com/
Upvotes: 0
Reputation: 7591
Compare validates the values are the same. are you sure you want the start and end times to be the same value? also how are the values set? it may be that they are off by a millisecond or two and therefore not equal.
Upvotes: 1