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 4256772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:24:01+00:00 2026-05-21T05:24:01+00:00

Basically, I just want allow select dates greater than today. I’d prefer this way

  • 0

Basically, I just want allow select dates greater than today. I’d prefer this way to avoid show alert messages.

  • 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-21T05:24:02+00:00Added an answer on May 21, 2026 at 5:24 am

    I don’t think that it is supported in the current version of the Toolkit to restrict selectable dates. This is a simple workaround handling the ClientDateSelectedChanged-Event and validate the selected date:

    How to make sure user does not select a date earlier than today or greater than today

    There could be instances where you do not want the user to select a day earlier than the current date. For example: when you are providing the user a form to book tickets, you would not like him to choose an earlier date. To achieve this requirement, use the following javascript code.

    Prevent the User from selecting a Date Earlier than today

    <head runat="server">
        <title>Calendar Extender</title>
        <script type="text/javascript">
    
        function checkDate(sender,args)
        {
            if (sender._selectedDate < new Date())
            {       
                alert("You cannot select a day earlier than today!");
                sender._selectedDate = new Date(); 
                // set the date back to the current date
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
             }
        }
        </script>
    </head>
    

    Call the code:

    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <div>
    
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <cc1:CalendarExtender ID="CalendarExtender1"
                runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />
    
            </div>
        </form>
    

    Select Date Greater than today

    In the javascript, just change this line
    sender._selectedDate > new Date()
    Note: You may argue that the user can still change the date by typing into the textbox or entering an invalid date. Well that can be easily handled using a ValidationControl and is covered in the next tip.

    Add validation to the CalendarExtender Control

    A simple way to add validation to the Calendar is to add a ValidationControl to the textbox associated with a CalendarExtender. You have two choices:

    1. Add an Extender to the ValidationControl. To do so, drag and drop a ValidationControl > click on the smart tag of the ValidationControl > choose Add Extender. From the Extender Wizard, choose ValidatorCalloutExtender. Using this approach makes it extremely easy to discover and attach control extenders to your controls. In VS 2005, you had to do this process manually, by wiring up control extenders.
    2. You can choose not to add the Extender.
      We will go ahead with option A. We will be adding two ValidationControls to the TextBox. The first, a CompareValidator to check if the user does not enter an invalid date (Eg: May 32) and second, a RangeValidator to keep the date range as desired.

    Adding CompareValidator

    <asp:CompareValidator ID="CompareValidator1" runat="server"
                    ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="Invalid Date"
                    Operator="DataTypeCheck" Type="Date">
    </asp:CompareValidator>
    <cc1:ValidatorCalloutExtender ID="CompareValidator1_ValidatorCalloutExtender"
                    runat="server" Enabled="True" TargetControlID="CompareValidator1">
    </cc1:ValidatorCalloutExtender>
    Adding RangeValidator – We will restrict the user to select a date range starting from today to 15 days from now.
    <asp:RangeValidator ID="RangeValidator1" runat="server"
                    ControlToValidate="TextBox1" ErrorMessage="RangeValidator"
                    Type="Date">
    </asp:RangeValidator>
    <cc1:ValidatorCalloutExtender ID="RangeValidator1_ValidatorCalloutExtender"
                    runat="server" Enabled="True" TargetControlID="RangeValidator1">
    </cc1:ValidatorCalloutExtender>
    

    In the code behind of your page, add this code
    C#

    protected void Page_Load(object sender, EventArgs e)
    {
        RangeValidator1.MinimumValue = System.DateTime.Now.ToShortDateString();
        RangeValidator1.MaximumValue = System.DateTime.Now.AddDays(15).ToShortDateString();
    }
    

    VB.NET

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            RangeValidator1.MinimumValue = System.DateTime.Now.ToShortDateString()
            RangeValidator1.MaximumValue = System.DateTime.Now.AddDays(15).ToShortDateString()
     End Sub
    

    Well those were some tips associated with the CalendarExtender. As future versions of the toolkit are released, we should be hopeful that there will exist easier ways, of achieving this functionality.

    From: http://www.dotnetcurry.com/ShowArticle.aspx?ID=149


    Another advanced approach would be to extend the CalendarExtender javascript, but then you have your own custom version of the ajax toolkit.

    http://codegoeshere.blogspot.com/2007/06/extending-calendarextender.html

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

Sidebar

Related Questions

Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
I'm writing an application that is basically just a preferences dialog, much like the
One simple method I've used in the past is basically just creating a second
I've just written a small XBox 360 Wireless Controller managed interface that basically wraps
Just got a request from my boss for an application I'm working on. Basically
Basically I have some code to check a specific directory to see if an
Basically I'm going to go a bit broad here and ask a few questions
Basically, I would like a brief explanation of how I can access a SQL
Basically I am trying to restart a service from a php web page. Here

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.