I am trying to implement custom validation in my MVC application. My scenario is
If Closed checkbox is checked, Start and End times are not required.
If Closed checkbox is not checked, I want user to select start and End times from dropdown.
If user select start and end times, I want to validate end time should be greater than start time.
I wrote a custom validation class as below. How can I validate this ?
public class DatesValidation : ValidationAttribute
{
public bool Closed { get; set; }
public string Start { get; set; }
public string End { get; set; }
public DatesValidation(bool closed, string startTime, string endTime)
{
this.Closed = closed;
this.Start = startTime;
this.End = endTime;
}
}
Aucun commentaire:
Enregistrer un commentaire