Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparevalidator error when dates span over different years

Status
Not open for further replies.

manjulam

Programmer
Feb 27, 2002
103
US
I have two date fields in my web form for which I need to do a normal Start Date-End Date validation. I am using a CompareValidator to do the same. I notice that it works for any combination except when the year part of the two dates are different. eg: Start Date=01/012005 and End Date-12/31/2004 will pass the validation.

Any ideas,anyone?

 
can you post what type of validation code you have running?
 
I think i got what was wrong! I was missing Type=Date property,so it was probably doing a string comparison.

<asp:comparevalidator id="CompareValidator3" runat="server" ErrorMessage="Start Date cannot be greater than End Date"
ControlToValidate="TextBox2" Display="None" Operator="LessThanEqual" ControlToCompare="TextBox3" Type="Date"></asp:comparevalidator>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top