views:

60

answers:

1

I'm setting the start date of an event using jQuery UI Datepicker.
Now I need to retrieve the date I selected.

I'm trying to use $('#startDate').datepicker('getDate'), but this returns NULL.

Using FirBug, I see that the input value is nothing>
<input type="text" name="startDate" value="" id="startDate" class="hasDatepicker">

So how can I retrieve the selected date?

PS. I found an old thread regarding he exact same issue.
http://old.nabble.com/ui.datepicker-trouble-td17846951s27240.html

But the solution here does not work for me. I just get an error message
uncaught exception: Missing instance data for this datepicke

UPDATE

I'm able to retrieve the selected date by using this code:

  var arr = $('#newEvent').serializeArray();
  alert(arr[2].value);

But this is by far the best way.... any othersuggestions is appreciated.

+1  A: 

You can use a callback to let it push it to your data :)

$('#startDate').datepicker({
    onChangeMonthYear: function(year, month, inst) { ... }
});
WoLpH
Thanks. Will try this.
Steven