For this you will need to use CustomValidator. In your markyou you will have something like this:
<asp:TextBox ID="txbStartDate" runat="server" />
<asp:TextBox ID="txbEndDate" runat="server" />
<asp:CustomValidator OnServerValidate="ValidateDuration"
ErrorMessage="Dates are too far apart" runat="server" />
And in your code behind you define a validation handler:
protected void ValidateDuration(object sender, ServerValidateEventArgs e)
{
DateTime start = DateTime.Parse(txbStartDate.Text);
DateTime end = DateTime.Parse(txbEndDate.Text);
int months = (end.Month - start.Month) + 12 * (end.Year - start.Year);
e.IsValid = months < 12.0;
}
, . , , , ValidateDuration , , .
, , , ( ) . , , .
<asp:CompareValidator Operator="GreaterThanEqual" Type="Date"
ControlToValidate="txbEndDate" ControlToCompare="txbStartDate"
ErrorMessage="Let get started first!" runat="server" />