Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    McG
    McG is offline
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JQuery Datepicker - minDate problem

    Hi all,
    I'm new to the forum and javascript.
    Im having a bit of an issue with the jquery datepicker.
    The datepicker is used to select a delivery date, with restrictions on what days can be picker from todays date.

    I want to be able to set the minDate to be 48 hours in advance.
    Unless today is the weekend, then first delivery is a Wednesday.

    I'll attach the code I have below, but any help would be grateful.

    Code:
    var dt = new Date();
    $("input[value*='EnterDate']").val('').datepicker({
    
    minDate:(dt.getDay() == 5 ? +5 : +3),
    
    });

  • #2
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    216
    Thanks
    0
    Thanked 29 Times in 27 Posts
    If 48 hours in advance, corresponds to a delivery in three days, the normal delivery date minDate is given by a gap of 3 days, You have only to increase this gap to avoid saturday and sunday !

    Code:
    var dt=new date(),gap=3,minDate;
    do {minDate=dt.setDate(dt.getDate()+gap);gap++;} while (minDate.getDay()==0 || MinDate.getDay()==6);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •