Using VS2005 ASP.NET / C#
Hi I have two text boxes that are populated with dates picked from a calendar control and I would like to validate that the date in textbox2 is greater than the date in textbox1. The compare validator will do the correct validation if the dates are in the same month ie dtSubmitted.text = 08/31/2008 & dtRequested.text = 08/01/2008 the validator control will kick in. However, if the dates are in different months ie, dtSubmitted.text = 07/31/2008 & dtRequested.text = 08/01/2008 then the form will submit without a validation error. How can I do a validation comparison that will take into account the actual full date and not just the day?
<tr>
<td align="right">
<asp:Label ID="lblDateSubmitted" runat="server" Text="DateSubmitted"></asp
:Label>
</td>
<td colspan="3">
<div id="cal1Container" style="DISPLAY: none; POSITION: absolute" ></div>
<asp:TextBox ID="dtSubmitted" Runat="server" OnTextChanged="dtSubmitted
_TextChang
ed"></asp:
TextBox>
<a id="chooseday" onclick="showCalendar1('<%
=dtSubmitted.ClientID %>',
'imgCalendar')" href="javascript:void(null
)">
<IMG id="imgCalendar" border="0" alt="" src="Images/pdate.gif">
</a>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblDateRequested" runat="server" Text="DateRequested"></asp
:Label>
</td>
<td colspan="3">
<div id="Div1" style="DISPLAY: none; POSITION: absolute" ></div>
<asp:TextBox ID="dtRequested" Runat="server"></asp:TextB
ox>
<a id="A1" onclick="showCalendar1('<%
=dtRequested.ClientID %>',
'imgCalendar')" href="javascript:void(null
)">
<IMG id="img1" border="0" alt="" src="Images/pdate.gif">
</a>
</td>
<td>
<asp:CompareValidator ControlToCompare="dtSubmit
ted" ControlToValidate="dtReque
sted" Operator="GreaterThan" ID="compDates" runat="server" ErrorMessage="*Date Requested Must Be Greater Than Or Equal To Date Submitted"></asp:CompareVa
lidator>
</td>
</tr>
<tr>
<td align="right">
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert" OnClick="InsertButton_Clic
k"></asp:L
inkButton>
</td>
</tr>
Start Free Trial