tags:

views:

130

answers:

4

Hi, im using datepicker v2. And I have a question. Is there a possibility to let the currentdate have a offset of 2 days. For example; today is it 14may. Can i let the datepicker start today with 16may? And that 14&15 aren't selectable?

Greetz from Belgium

A: 

This should do it:

var twoDaysTijmeStr = (new Date()).addDays(2).asString;
$('.kalendertje')
    .val(twoDaysTijmeStr)
    .datePicker(
    {
        clickInput: true,
        startDate: twoDaysTijmeStr
    }
);

Let me know if you have any problems with it...

vitch
A: 

works!

$(function()
{
    $('.date-picker').datePicker({clickInput:true}).val(new Date().addDays(2).asString()).trigger('change');
}

but the today-date is selectable.. i dont want that date to be selectable..

RihanU
I just updated the example in my answer to reflect the further information here... You need to set a startDate as well as the selected date and setting the selected date shouldn't be necessary if you set the val on the input before calling the date picker...
vitch
dunnow where my answer is, but thanks again. it works fine! :)now i had to do some changes so he doesn't count the weekends :p
RihanU
A: 

You need to add the days to the date before you cast it to a string. Try changing

$(function()
{
    $('.date-picker').datePicker({clickInput:true}).val(new Date().asString()).addDays(2).trigger('change');
});

to

$(function()
{
    $('.date-picker').datePicker({clickInput:true}).val(new Date().addDays(2).asString()).trigger('change');
});

EDIT: Sorry, didn't see the last requirement that today and tomorrow should not be selectable. Try

$(function()
{
    $('.date-picker').datePicker({clickInput:true, startDate: new Date().addDays(2).asString()}).val(new Date().addDays(2).asString()).trigger('change');
});
AdmSteck
thanks! this works for me :)
RihanU
A: 

Is there a possibility for skipping the weekends with counting? For example; it is Saturday. So it has to be the Tuesday that will be selectable first.

RihanU