Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5931449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:41:47+00:00 2026-05-22T14:41:47+00:00

i use two CalendarExtender to combine two dates: start date and end date and

  • 0

i use two CalendarExtender to combine two dates: start date and end date and i use a compare validator to validate that the end date is greater than the start date.

the problem that the validator fires when the day in the end date is smaller than the day in the start date even though the whole end date is greater than the whole start date ..

how to fix this problem?

my aspx:

1-start date:

<asp:TextBox ID="txt_startDate" runat="server" ValidationGroup="insertgroup" MaxLength="10"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_startDate"
    ErrorMessage="!" ValidationGroup="insertgroup"></asp:RequiredFieldValidator>
<cc1:MaskedEditExtender ID="txt_startDate_MaskedEditExtender" runat="server" CultureAMPMPlaceholder=""
    CultureCurrencySymbolPlaceholder="" CultureDateFormat="" CultureDatePlaceholder=""
    CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" CultureTimePlaceholder=""
    Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="txt_startDate">
</cc1:MaskedEditExtender>
<cc1:CalendarExtender ID="txt_startDate_CalendarExtender" runat="server" Enabled="True"
    TargetControlID="txt_startDate" Format="dd/MM/yyyy">
</cc1:CalendarExtender>

2-end date:

<asp:TextBox ID="txt_endDate" runat="server" ValidationGroup="insertgroup" MaxLength="10"></asp:TextBox>
<cc1:CalendarExtender ID="txt_endDate_CalendarExtender" runat="server" TargetControlID="txt_endDate"
    Format="dd/MM/yyyy">
</cc1:CalendarExtender>
<cc1:MaskedEditExtender ID="txt_endDate_MaskedEditExtender" runat="server" CultureAMPMPlaceholder=""
    CultureCurrencySymbolPlaceholder="" CultureDateFormat="" CultureDatePlaceholder=""
    CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" CultureTimePlaceholder=""
    Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="txt_endDate">
</cc1:MaskedEditExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="txt_endDate"
    Display="Dynamic" ErrorMessage="!" ValidationGroup="insertgroup"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txt_startDate"
    ControlToValidate="txt_endDate" Display="Dynamic" ErrorMessage="????? ??????? ??? ?? ???? ??? ?? ????? ???????"
    Operator="GreaterThan" Type="Date" ValidationGroup="insertgroup"></asp:CompareValidator>

EDIT:
Example for two dates make problems:

//error message
    start date: 
    28/01/2014

    end date :
    25/07/2014

while

// no error message
    start date: 
    28/01/2014

    end date :
    01/07/2014
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:41:48+00:00Added an answer on May 22, 2026 at 2:41 pm

    Here’s some more information as to why you’re getting this behavior, and why Chad’s code will help you.

    Right now your application is running under a culture setting that says dates should be mm/dd/yyyy (your computer or the webserver is working like an American). If you look at the javascript that ASP.NET emits for the Validators, you’ll see that when doing a comparison it first checks whether the datatype of the ControlToValidate is correct. It does this by parsing the entered value with a RegEx, and expects the month value to be first and then the day (because of the culture setting). When it sees your value of 25, it doesn’t think this is a valid month, and hence says that your date is not valid. It then returns false, without even checking the second field’s date value or trying to compare them.

    In your second example, validation passes because first, it checks the datatype of the end date, which CAN be a valid mm/dd/yyyy date. Then it checks the datatype of the second date, which because of the 28, causes it to think it’s not a valid date. The validator then returns true, because it assumes that a valid date is greater than a non-valid date.

    Chad’s code will set the culture of your page’s thread to one that uses the dd/MM/yyyy format, and therefore your validators will use that when checking whether your dates are valid.

    Here’s the MSDN page with more info about the culture settings and what they do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Java webservice application (with JAX-WS) that has to use two
I'm trying to use two listviews (that are on same page - wpf) to
I am building a search form that use two different javascript scripts. This is
I'm making a C program that needs to use two stacks. One needs to
I could use two loops to check for all combinations of two integers that
i use two datepickers to get the arrival and the departure date, counting the
I must use two validator for one fields: $this->setValidator('number', new sfValidatorDoctrineUnique( array('model' => 'Data',
I use two Spinner in my App. One of them is initially disabled because
Can I use two different back ends for an .net Entity Framework project? I
Can you use two regex in preg_replace to match and replace items in an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.