Reputation: 95
I want to implement a Data annotation attribute to validate dates. I know something similar already exists like
[Range(typeof(DateTime), "1/2/2004", "3/4/2004", ErrorMessage = "Value for {0} must be between {1} and {2}")]
But this code obliges me to set a static data. Instead I would like to set the name of a textbox that contains a data.
This will be the html code
<input type="text" name="startdate" />
<input type="text" name="enddate" />
and this the C# code
public class event {
public ....
[Range(DateTime.Today, "enddate")]
public startdate {set;get;}
[Range("startdate", "01/01/2014")]
public enddate {set;get;}
}
Somebady can help me with the code? thanks
Upvotes: 3
Views: 3351