0

I am using jQuery UI for an inline datepicker. By simply calling it on a <div> I get a nice inline datepicker, but I do not see how I can set the default date that is to be selected.

JS:

$("div.date").datepicker({});

HTML:

<div class="date"></div>

user852091
  • 3,070
  • 5
  • 23
  • 21
  • Already answered at http://stackoverflow.com/questions/233553/how-do-i-pre-populate-a-jquery-datepicker-textbox-with-todays-date – Sriram Jul 20 '11 at 02:47

2 Answers2

1

Have you tried using the defaultDate option? From the docs:

Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current dateFormat, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.

Code examples

Initialize a datepicker with the defaultDate option specified.

$( ".selector" ).datepicker({ defaultDate: +7 });
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
0

Call $('div.date').datepicker( "setDate" , date); or you can set the default prior to opening as displayed by Justin Ethier

Akkuma
  • 2,215
  • 3
  • 16
  • 21