0
I wanted to know if you have how to validate if the Date entered is higher or not than the current date using Annotation, or if I have to deal with the same controller. If you can, please provide an example.
0
I wanted to know if you have how to validate if the Date entered is higher or not than the current date using Annotation, or if I have to deal with the same controller. If you can, please provide an example.
4
You can do this by creating a class that derives from RangeAttribute
:
public class DateAttribute : RangeAttribute
{
public DateAttribute()
: base(typeof(DateTime), DateTime.Now.ToShortDateString(), DateTime.MaxValue.ToShortDateString()) { }
}
Browser other questions tagged asp.net-mvc-5 validation annotation
You are not signed in. Login or sign up in order to post.
I liked that answer here too, but it’s on SOF in English. I don’t know what the policy is for the use of English community information here on.SOF: http://stackoverflow.com/questions/19882296/mvc4-data-annotation-compartwo-dates
– StillBuggin
@Stillbuggin I put the link to the question in my answer
– Bruno Costa