Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET validation , +
<asp:TextBox ID="txt_dateofjoin" runat="server" />
<cc1:CalendarExtender ID="cal2" runat="server" TargetControlID="txt_dateofjoin" Format="dd-MM-yyyy" TodaysDateFormat="dd-MM-yyyy"></cc1:CalendarExtender>
 
<asp:TextBox ID="txt_confirmationdate" runat="server" />
<cc1:CalendarExtender ID="cal" runat="server" Format="dd-MM-yyyy" TargetControlID="txt_confirmationdate" TodaysDateFormat="dd-MM-yyyy">
</cc1:CalendarExtender>
 
<asp:CompareValidator ID="cmpDates" runat="server" ControlToCompare="txt_dateofjoin" ControlToValidate="txt_confirmationdate" Operator="GreaterThan" Type="Date" SetFocusOnError="true" Display="Dynamic" Text="Confirm Date must be greater than Joining Date" />
 
when I change the Format of CalendarExtender to MM-dd-yyyy then it works fine but in dd-MM-yyyy compare validator consider date to month. Now how I can validate this two date in dd-MM-yyyy format.
Posted 19-Aug-12 19:47pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Try setting the property CultureInvariantValues="true" in your CompareValidator .
 
--Amit
  Permalink  
Comments
Dinesh Ambaliya at 20-Aug-12 1:35am
   
it's not work!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Rewrite your tag for calender extender in following way its solved your problem...
 
<cc1:CalendarExtender ID="cal2" runat="server" TargetControlID="txt_dateofjoin"
Format="dd/MM/yyyy" TodaysDateFormat="dd/MM/yyyy"></cc1:CalendarExtender>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 420
1 OriginalGriff 230
2 DamithSL 175
3 Dave Kreskowiak 120
4 Zoltán Zörgő 114
0 OriginalGriff 7,740
1 DamithSL 5,644
2 Sergey Alexandrovich Kryukov 5,404
3 Maciej Los 5,011
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 20 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100