I have this class overriding the RangeAttribute:
public class RangeDateAttribute : RangeAttribute
{
public RangeDateAttribute()
: base(typeof(DateTime),
DateTime.Now.AddYears(-20).ToShortDateString(), DateTime.Today.ToShortDateString()) { }
}
DataAnnotation for my attribute:
[RangeDate(ErrorMessage = "Value for {0} must be between {1} and {2}")]
public DateTime anyDate { get; set; }
I'm using the method [ToShortDateString()] in that validation, but when displays the error, it comes with the time.. Ex:
Value for anyDate must be between 26/05/1995 00:00:00 and 26/05/2015 00:00:00
How can I solve this?
Thanks.