engineer9090909090909090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Set Today to deselect #270

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've been struggling with this problem - i want to restrict the user from being 
able to select today (at the least) as an option. 

Ideally it would actually be if selection occurs after 5pm then date to be 
selected could not be today or tomorrow but the following day.

i've been trying to use Date() but i seem to only cause either everything to 
become deselected or nothing

any ideas? thanks in advance

Original issue reported on code.google.com by digitalg...@gmail.com on 30 Mar 2011 at 9:13

GoogleCodeExporter commented 8 years ago
ok i think i have a solution - check it! 

.datePicker(
    {
        startDate: (new Date()).addHours(24).asString(),
        endDate: '01/01/2999',
    }
        )

Seems to be working and i tested it out at the end of the month (between the 
31st of march and april 1st)

hope this helps someone

Original comment by digitalg...@gmail.com on 31 Mar 2011 at 4:24

GoogleCodeExporter commented 8 years ago
Glad you figured it out.. 

(new Date()).addDays(1).asString()

Should also have worked...

To deal with the "after 5pm" thing you could do something like:

var startDate = (new Date()).addDays(1);
if (startDate.getHours() > 17) {
  startDate.addDays(1);
}
/* selector */.datePicker(
  {
    startDate: startDate.asString(),
    endDate: '01/01/2999'
  }
)

(also note that there shouldn't be a trailing comma after endDate as you have 
in the code above - this will cause problems in IE)

Original comment by kelvin.l...@gmail.com on 14 Apr 2011 at 7:36