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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:26:33+00:00 2026-05-24T06:26:33+00:00

I am a novice using jQuery UI datepicker on a commerce site to set

  • 0

I am a novice using jQuery UI datepicker on a commerce site to set a shipping date. I want to populate the date input field with the first valid shipping date, which is defined as:

  • later than today; and
  • either a Monday or a Tuesday

(There are other conditions, but I am ignoring them for the moment.)

As I write this, and for the next few days, the correct value of this date is 8/8/2011.

Here is the page:

http://www.lolacookies.com/gifts/

Here is my code, which is not working. The commented part is what’s supposed to be doing the work. The value of the input is not being set at all; in previous attempts the date has been set to the value of minDate, but not to any other value.

$(document).ready(function(){


$(".datepicker").datepicker({
    beforeShowDay: nonWorkingDates,
    hideIfNoPrevNext: true,
    numberOfMonths: 1,
    minDate: "+1d",
    maxDate: "+3M",
    showAnim: "blind",
    showOn: "both",
    buttonImage: "/images/misc/calendar.png",
    buttonImageOnly: true,
    buttonText: "Select a date"
});


//set firstShippingDate to value of minDate
//we don't ship on same day, so minDate is today + 1d
var firstShippingDate = $( ".datepicker" ).datepicker( "option", "minDate" );

//we ship only on Monday and Tuesday, so test for that
var dayOfWeek = firstShippingDate.getDay();

//if it's not Monday or Tuesday, advance firstShippingDate by one day and test again
while ( dayOfWeek == 0 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 5 || dayOfWeek == 6 )
  {
    firstShippingDate.setTime(firstShippingDate.getTime() + 86400000);
    dayOfWeek = firstShippingDate.getDay();
  };

//should exit loop with firstShippingDate set to first Monday or Tuesday that's not today
//set datepicker to that firstShippingDate
$(".datepicker").datepicker( "setDate" , firstShippingDate );


function nonWorkingDates(date){
    var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
    var closedDates = [[06, 27, 2011], [06, 28, 2011], [06, 29, 2011], [07, 04, 2011]];
    var closedDays = [[Sunday], [Wednesday], [Thursday], [Friday], [Saturday]];
    for (var i = 0; i < closedDays.length; i++) {
        if (day == closedDays[i][0]) {
            return [false];
        }

    }

    for (i = 0; i < closedDates.length; i++) {
        if (date.getMonth() == closedDates[i][0] - 1 &&
        date.getDate() == closedDates[i][1] &&
        date.getFullYear() == closedDates[i][2]) {
            return [false];
        }
    }

    return [true];
}


});
  • 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-24T06:26:34+00:00Added an answer on May 24, 2026 at 6:26 am

    You might want to checkout the DateJS library. It let’s you do cool stuff like this to get the next monday:

    Date.today().next().monday();
    

    So in your case, you can do something like this to get the next monday or tuesday:

    if (Date.today().is().monday()) {
      firstShippingDate = Date.today().next().tuesday();
    } else {
      firstShippingDate = Date.today().next().monday();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a search using CI and Jquery, well i'm very novice to this,
I'm using JQuery UI for various things, one being the datepicker. I've notice it's
I'm using jQuery Masonry (google it, it's super awesome) for my site's dynamic layout.
I'm a complete perl novice, am running a perl script using perl 5.10 and
I'm an ASP.NET web part novice. I've built a few simple ones using only
As a novice developer who is getting into the rhythm of my first professional
I am a AS3 novice learning PureMVC and want to write code following best
I have a large nested list that I am trying to animate using jquery
I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My
I’m planning on using Ajax with my web application, but as I’m novice and

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.