I have a DateTime, and need to validate that ... I need that my DateTime stay Between two other Datetime (dynamic)...
How Can I do that?
I have a DateTime, and need to validate that ... I need that my DateTime stay Between two other Datetime (dynamic)...
How Can I do that?
I like to use Fluent Validation. It gives you a lot more control over your validation.
With FluentValidation, you would do something like this (where MyDateTime, date1, and date2 are properties of your MyModel class) :
Just declare a custom ValidationAttribute
or if you are using a datepicker, you can restrict the minDate and maxDate like this:
Hope this help :)
You can implement IValidatableObject.