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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:14:33+00:00 2026-05-23T16:14:33+00:00

I am using two jquery on one page. On Document ready one of them

  • 0

I am using two jquery on one page. On Document ready one of them is set to the current date, the other is set to the current date + 15 days

What I am trying to do is make the second calendar never allow to choose a date that is earlier to the first +15 days.

Example : on Document ready calendar 1 : shows 07/05/11 calendar 2 : shows 07/20/11,If i choose 7/21/11 on calendar then calendar 2 should display : 07/05/11. only on the focus of the second datepicker input field will the value of the field change to the 5th and display correctly in calendar view. It should do this automatically.

Here is an example of how this is being handled

// Setting the current date and adding 15 days 

function setRange() {
    d=new Date($('#dateofchange').datepicker('getDate'));
    d.setDate(d.getDate() + 15);
    $('#EffectiveDate').datepicker('option', 'minDate', new Date(d));
    d=new Date($('#dateofchange').datepicker('getDate'));
    d.setFullYear(d.getFullYear() + 1);
    $('#EffectiveDate').datepicker('option', 'maxDate', new Date(d));
}

// This is the initial datePicker

$('#dateofchange').datepicker({
    showButtonPanel: true,
    minDate: new Date()
    });

// This is the current Date plus 15 days. 

$('#EffectiveDate').datepicker({
    showButtonPanel: true,
    beforeShow: setRange
});
  • 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-23T16:14:34+00:00Added an answer on May 23, 2026 at 4:14 pm

    I would rewrite it a tad and do it something like this.

    When a date gets selected in the #dateofchange datepicker, the minDate and maxDate options of the #EffectiveDate will get set again, based on the date the user has selected.

    function addDays(date) {
        var d = new Date(date);
        d.setDate(d.getDate() + 15);   
        return d;
    }
    function addYear(date){
        var d = new Date(date);
        d.setFullYear(d.getFullYear() + 1);
        return d;
    }
    
    $('#dateofchange').datepicker({
        showButtonPanel: true,
        minDate: new Date(),
    
        // change EffectiveDate minDate and maxDate when the user selects a date in #dateofchange
        onSelect:function(dateText, inst) {
            var d = new Date(dateText);
            $("#EffectiveDate").datepicker( "option", "minDate", addDays(d));
            $("#EffectiveDate").datepicker( "option", "maxDate", addYear(d));        
        }
    });
    
    $('#EffectiveDate').datepicker({
        showButtonPanel: true,
        minDate: addDays(new Date()),
        maxDate: addYear(new Date())
    });
    

    It could probably be written a bit more concise and elegant, but this should function the way you described.

    jsFiddle: http://jsfiddle.net/bjorn/aVBca/2/

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

Sidebar

Related Questions

I am trying to make two ajax requests in parallel using jQuery like this:
I'm using the jQuery Validation JS I have two contact forms, the main one
how i do validate two date textboxes using jquery. i came across this snippet
I'm using the jQuery datepicker where I have two textboxes (start date / end
I'm putting together a fixed, one-page site that deploys an overlay using jQuery. There
I have two pages. One aspx page and the other an aspx page but
I'm trying to make a slideshow using Jquery, the pictures are cycled by a
I'd like to check ancestry using two jQuery objects. They don't have IDs, and
I'm currently using two libraries (prototype and jQuery), thus I've implemented the jQuery noConflict
I'm using a JQuery UI slider which has two handles (a.k.a range slider). I

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.