Hi,
I'm having problems with validating dates using the UI datepicker.
I have a date textbox where the date cannot be earlier then tomorrow and it is a required field. See code below:
- <asp:Label ID="uxDateLabel" runat="server" AssociatedControlID="uxDate" Text="Date cover is to begin"></asp:Label>
<asp:TextBox ID="uxDate" CssClass="futuredatepicker" runat="server" ></asp:TextBox>
<div class="clear"></div>
<asp:RangeValidator ID="uxDateRangeValidator" runat="server" ControlToValidate="uxDate"
CssClass="errorMessage" Display="Dynamic"
ErrorMessage="The earliest date you can enter is tomorrow" Type="Date" ValidationGroup="ChangeDetails" />
<asp:RequiredFieldValidator ID="uxBlankDateValidator" runat="server" ControlToValidate="uxDate"
CssClass="errorMessage" Display="Dynamic" InitialValue="" ErrorMessage="When would like cover to begin"
ValidationGroup="ChangeDetails">
</asp:RequiredFieldValidator>
In the code behind, the Range validator is set (in the page_load event):
- uxDateRangeValidator.MinimumValue = DateTime.Now.AddDays(1).ToString("d");
uxDateRangeValidator.MaximumValue = DateTime.Now.AddYears(5).ToString("d");
And the jquery is set like so:
- $(document).ready(function()
{
$( '.futuredatepicker' ).datepicker(
{ dateFormat: 'dd/mm/yy',
minDate: 1
});
});
Now, this works perfectly in all browsers apart from Internet Explorer. The test the client has performed is to select a date with the datepicker, then manually change the date in the text box to one outside the date range (at which point the RangeValidator displays the error message), then he selects a date within the accepted range from the datepicker. Once the new date has been selected, the RangeValidator error message remains in Internet Explorer, while it disappears in every other browser! With IE, the error message stays and you can't complete the form.
Anyone got any ideas why this might be happening?