ASP.NET - Compare validator stranger problem - Asked By mostafa hamdy on 12-Feb-12 10:39 AM

Hello all
I have some web site built with 4.0 and some page have two datepickers which fill in to text box and some comparevalidator which compares between the start and the end dates , the end date have to be greater  than or equal start date,this page work correctly when I test it with windows7 and IE8 , but when I tested it with windows XP and IE 8 I get some stranger problem that if the Enddate greater than the Startdate the compare validator alert me with the error message this happend only with windows XP, please if any body get what I mean and can help me please send me or tell me about some URL may help me in doing that, below is the code which I did

<asp:CompareValidator ID="CompareValidatorDate" runat="server" ControlToCompare="txtLicenseDate"

ControlToValidate="txtLicenseRenewalDate" ErrorMessage="EndDate have to be greater than or equal startdate"

Font-Bold="False" Operator="GreaterThanEqual" Type="Date"></asp:CompareValidator>

<asp:TextBox ID="txtLicenseDate" runat="server" meta:resourcekey="txtLicenseNo" CssClass="TextboxSty2"></asp:TextBox>

<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtLicenseDate"



<asp:TextBox ID="txtLicenseRenewalDate" runat="server" meta:resourcekey="txtLicenseNo"

CssClass="TextboxSty2" onchange="validateCheck();"></asp:TextBox>

<asp:CalendarExtender ID="txtLicenseRenewalDate_CalendarExtender" runat="server"

TargetControlID="txtLicenseRenewalDate" Format="dd/MM/yyyy">


Web Star replied to mostafa hamdy on 12-Feb-12 11:12 AM
As i understand this is not issue with window 7 or xp, in my point of view this is issue of datetime format on the system.
If you put validation based on dd/mm/yy and other system's date setting with mm/dd/yy than such type of problem happen so first check that things.
D Company replied to mostafa hamdy on 12-Feb-12 12:12 PM
Hello Friend,

The best option to avoid this problem is Use a custom validator for client side validation. with a datetime
validation script as the validationscript.and it will have no conflict whether you use any os any plateform

and server side

something like

datetime.parse (myVariable);
catch (exception ex)

Hope it helps!!