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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:57:50+00:00 2026-05-25T22:57:50+00:00

I have two datepickers at the moment, one for a start date, and another

  • 0

I have two datepickers at the moment, one for a start date, and another for an end date.

When you select the first date, I’d like the default value of the second datepicker to be set to the same date. If I use the setDate it works and sets the value just fine, but the default value won’t change – if I set the defaultDate when the datepicker is loaded, it works, but if I try to set it on the fly it doesn’t.

Here’s my code:

if($('#startDate').val().length == 10 && $("#endDate").val().length != 10) {
    $("#endDate").datepicker("defaultDate", $("#startDate").datepicker("getDate"));
}

(edit) for clarification, I don’t want to set the date – the user needs to do that, but I’d like the datepicker to go straight to the same date as the start date, to save them having to trawl through numerous pages.

Here’s the (kinda) working code: http://jsfiddle.net/c8H5y/

Any suggestions would be very welcome, thank you!

  • 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-25T22:57:51+00:00Added an answer on May 25, 2026 at 10:57 pm

    This should do it:

    $("#dep_date").datepicker({
        dateFormat: 'dd/mm/yy',
        onSelect: function(dateText, inst) {
            var date = $.datepicker.parseDate('dd/mm/yy', dateText);
            var $ret_date = $("#ret_date");
            $ret_date.datepicker("option", "defaultDate", date);
        }
    });
    
    $("#ret_date").datepicker({
        dateFormat: 'dd/mm/yy',
    });
    

    jsFiddle

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

Sidebar

Related Questions

I have Silverlight 3 application with two datepickers for Start Date and End Date.
I'm using the jQuery datepicker where I have two textboxes (start date / end
I have two inline datepickers on my page to select a date range: As
I have two datepicker fields, one is ' start date ' the other is
I have two datepickers: $('#Date1, #Date2').datepicker({ defaultDate: +1, minDate: +1 }); Whenever I select
In my view, I have two date fields like so: <%= f.text_field :start_date %>
I've got two date pickers in one form. They have different id's so this
H I need to customize two datepickers. First shold have: minDate: last ten days
I have two identical tables and need to copy rows from table to another.
I have two classes, and want to include a static instance of one class

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.