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

  • SEARCH
  • Home
  • 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 8135717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:30:31+00:00 2026-06-06T10:30:31+00:00

Hi I found the following code from this page JQuery UI DatePicker using 2

  • 0

Hi I found the following code from this page JQuery UI DatePicker using 2 date fields trying to get date difference

However I don’t understand the datepicker ui enough to be able to stop the first datepicker from letting you only select from todays date. Im sure its simple but can someone please help!

<script type="text/javascript">
    var DatePicked = function() {
            var departure = $("#CheckIn");
            var arrival = $("#CheckOut");
            var nights = $("#Nights");

            var triggeringElement = $(this);

            var minArrivalDate = new Date();

            var departureDate = departure.datepicker("getDate");

            if (departureDate != null) {
                    minArrivalDate.setDate(departureDate.getDate() + 1);
            } else {
                    minArrivalDate.setDate(minArrivalDate.getDate() + 1);
            }
            arrival.datepicker('option', 'minDate', minArrivalDate);

            var arrivalDate = arrival.datepicker("getDate");

            if (departureDate != null && arrivalDate != null && triggeringElement.attr("id") != "Nights") {
                    var oneDay = 1000*60*60*24;
                    var difference = Math.ceil((arrivalDate.getTime() - departureDate.getTime()) / oneDay);
                    nights.val(difference);
            } else if (departureDate != null && triggeringElement.attr("id") == "Nights") {
                    var nightsEntered = parseInt(nights.val());
                    if (nightsEntered >= 1) {
                            var newArrivalDate = new Date();
                            newArrivalDate.setDate(departureDate.getDate() + nightsEntered);
                            arrival.datepicker("setDate", newArrivalDate);
                    } else {
                            alert("Nights must be greater than 1.");
                    }
            }
    }
    $(function() {
            $("#CheckIn, #CheckOut").datepicker({
                    onSelect: DatePicked
            });
            $("#Nights").change(DatePicked);
            DatePicked();
    });
</script>

Form:

<form class="enquiry" action="assets/scripts/booking.php" method="get" name="Booking">
<div class="Widget_Form_Spacer">
<label for="CheckIn">Check-In</label>
<input id="CheckIn" name="CheckIn" type="text" class="tF bL" value="<?php echo date("m/d/Y"); ?>" />
</div>
<div class="Widget_Form_Spacer Right">
<label for="CheckOut">Check-Out</label>
<input id="CheckOut" name="CheckOut" type="text" class="tF bL" value="" />
</div>
<div class="Widget_Form_Spacer Short">
<label for="Nights">Nights</label>
<input id="Nights" name="Nights" type="text" class="tF nL" value="1" onclick="clickclear(this, '1')" onblur="clickrecall(this,'1')" />
</div>
<div class="Widget_Form_Spacer Short">
<label for="Adults">Adults</label>
<input name="Adults" type="text" class="tF nL" value="1" onclick="clickclear(this, '1')" onblur="clickrecall(this,'1')" />
</div>
<div class="Widget_Form_Spacer Long">
<input name="Check" type="submit" value="Check Availability" />
</div>
</form>
  • 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-06-06T10:30:33+00:00Added an answer on June 6, 2026 at 10:30 am

    You can use the minDate jquery UI datepicker option:

    $("#date").datepicker({ minDate: new Date() });
    

    Live DEMO

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

Sidebar

Related Questions

Ok so i am using the following jquery dropdown menu. I found this code
I am running the following jQuery .get() call from an HTML page: <div id=fw_results>Results</div>
At a website , I found the following code to make a jQuery plugin:
Using the code found here: How to popup a jquery window to play youtube
I want to send a variable from my php page to my jquery code.
I found the following code somewhere, but I am not understanding the code properly.
I found the following code in my team's project: Public Shared Function isRemoteDisconnectMessage(ByRef m
I've found the following code: https://github.com/roddi/ValidateStoreReceipt/blob/master/validatereceipt.m which loads the root certificate ('Apple Root CA')
The following code can be found in the NHibernate.Id.GuidCombGenerator class. The algorithm creates sequential
The following javascript code concatenates the matches found by a regular expression. The regular

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.