I would like to know how to set a conditional requirement on a DateTime property. That is, in addition to check whether or not this required field is empty, I want the input (in a cshtml file) to be no sooner than 3 weeks from today.
Model:
[DataType(DataType.Date)]
[Display(Name = "Start date"), Required(ErrorMessage = ValidationMessages.IsRequired)]
//[What else here for this condition??]
public DateTime StartDate { get; set; }
.cshtml:
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.Assignment.StartDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Assignment.StartDate)
@Html.ValidationMessageFor(model => model.Assignment.StartDate)
</div>
</div>
How would such a conditional expression look like? Need I add something besides the condition in the model?
And please say if my description is too scanty.
// Thanks in advance, Regards