c# - Compare two input fields in asp.net mvc -
this question has answer here:
- mvc validation lower/higher other value 4 answers
i have 2 properties in model class:
public datetime startdate { get; set; } public datetime enddate { get; set; }
here,startdate
should less enddate
there data annotation in asp.net mvc
there option write own custom attribute, shown in this answer.
another option use foolproof (available nuget).
public class eventviewmodel { [required] public string name { get; set; } [required] public datetime start { get; set; } [required] [greaterthan("start")] public datetime end { get; set; } }
Comments
Post a Comment