<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
StartDate.MinDate = DateTime.Today.AddMonths(-1);
StartDate.MaxDate = DateTime.Today.AddMonths(1);
CompareToValueValidator1.ValueToCompareAsNative = DateTime.Today;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (PeterBlum.DES.Globals.WebFormDirector.IsValid)
{
}
}
</script>
<p>These two DateTextBoxes are associated with numerous validators. Assign different dates to see how each validator responds.</p>
Start Date:
<des:DateTextBox ID="StartDate" runat="server" SpecialDatesControlID="SpecialDates1"
DateFormat="Abbreviated">
</des:DateTextBox><br/>
End Date:
<des:DateTextBox ID="EndDate" runat="server">
</des:DateTextBox><br/>
<br/>
<des:Button ID="Button1" runat="server" Text="Validation and Submit" OnClick="Button1_Click" />
<br/>
<br/>
<h2>DataTypeCheckValidator</h2>
<a href="../../Validation/Validators/Controls/DataTypeCheckValidator.aspx" class="ControlClass">DataTypeCheckValidator</a> on both textboxes (always add these validators. Do not assume client-side formatting features
of the DateTextBox will protect you)<br/><br/>
<des:DataTypeCheckValidator ID="DataTypeCheckValidator1" runat="server" ControlIDToEvaluate="StartDate"
ErrorMessage="Invalid entry in Start Date"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet on StartDate">
</des:DataTypeCheckValidator>
<des:DataTypeCheckValidator ID="DataTypeCheckValidator2" runat="server" ControlIDToEvaluate="EndDate"
ErrorMessage="Invalid entry in End Date"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet on EndDate">
</des:DataTypeCheckValidator>
<br/>
<br/>
<h2>CompareTwoFieldsValidator</h2>
<a href="../../Validation/Validators/Controls/CompareTwoFieldsValidator.aspx" class="ControlClass">CompareTwoFieldsValidator</a> where Start Date is less than End Date<br/><br/>
<des:CompareTwoFieldsValidator ID="CompareTwoFieldsValidator1" runat="server" SecondControlIDToEvaluate="EndDate"
ControlIDToEvaluate="StartDate" ErrorMessage="Make Start < End" Operator="LessThan"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet" >
</des:CompareTwoFieldsValidator>
<br/>
<br/>
<h2>CompareToValueValidator</h2>
<a href="../../Validation/Validators/Controls/CompareToValueValidator.aspx" class="ControlClass">CompareToValueValidator</a> where the date must be greater than Today.<br/><br/>
<des:CompareToValueValidator ID="CompareToValueValidator1" runat="server" ControlIDToEvaluate="StartDate"
ErrorMessage="Make Start={VALUETOCOMPARE}" Operator="GreaterThan"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet">
</des:CompareToValueValidator>
<br/>
<br/>
<h2>RangeValidator</h2>
<a href="../../Validation/Validators/Controls/RangeValidator.aspx" class="ControlClass">RangeValidator</a> where Start Date must be between one month ago and one month from now.<br/><br/>
<des:RangeValidator ID="RangeValidator1" runat="server" ControlIDToEvaluate="StartDate"
ErrorMessage="Start Date must be between {MINIMUM} and {MAXIMUM}"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet">
</des:RangeValidator>
<br/>
<br/>
<h2>UnselectableDatesValidator</h2>
<a href="../SpecialDates/DateTextBox with unselectable dates.aspx" class="ControlClass">UnselectableDatesValidator</a> uses the SpecialDates control to identify unselectable dates.
In this example, Saturdays and Sundays are unselectable.<br/><br/>
<des:UnselectableDatesValidator ID="UnselectableDatesValidator1" runat="server" ControlIDToEvaluate="StartDate"
ErrorMessage="Not on Sundays!"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet">
</des:UnselectableDatesValidator>
<des:SpecialDates ID="SpecialDates1" runat="server">
<des:SpecialDayOfWeek DayOfWeek="Saturday" Selectable="Unselectable" ></des:SpecialDayOfWeek>
<des:SpecialDayOfWeek DayOfWeek="Sunday" Selectable="Unselectable" ></des:SpecialDayOfWeek>
</des:SpecialDates>
<br/>
<br/>
<h2>DifferenceValidator</h2>
<a href="../../Validation/Validators/Controls/DifferenceValidator.aspx" class="ControlClass">DifferenceValidator</a> where the two dates must be more than 5 days apart.<br/><br/>
<des:DifferenceValidator ID="DifferenceValidator1" runat="server" SecondControlIDToEvaluate="EndDate"
ControlIDToEvaluate="StartDate" DifferenceValue="5" ErrorMessage="More than 5 days difference"
Operator="GreaterThan" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet">
</des:DifferenceValidator>
<br/>
<br/>
<h2>RequiredTextValidator</h2>
<a href="../../Validation/Validators/Controls/RequiredTextValidator.aspx" class="ControlClass">RequiredTextValidator</a> on Start Date<br/><br/>
<des:RequiredTextValidator ID="RequiredTextValidator1" runat="server"
ControlIDToEvaluate="StartDate" ErrorMessage="Requires an entry"
NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet" >
</des:RequiredTextValidator>