Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2013, 12:19 PM   PM User | #1
McG
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
McG is an unknown quantity at this point
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),

});
McG is offline   Reply With Quote
Old 01-11-2013, 01:21 PM   PM User | #2
007julien
Regular Coder

 
Join Date: May 2012
Location: France
Posts: 115
Thanks: 0
Thanked 17 Times in 15 Posts
007julien is an unknown quantity at this point
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);
007julien is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:20 AM.


Advertisement
Log in to turn off these ads.