views:

93

answers:

2

I am using JQueryUI datepicker. I am currently using following:

$('#dtpicker').datepicker('getDate');

to get date from the datepicker. This function by default gets me today's date if the user has not selected any date in the picker. Is there some function which gets the date the user has selected? For example, if the user has selected today's date, the function should return today's date. If he didnt select any date, then this function should return false, perhaps.

I want this function for validation of date ranges in JQueryUI daterangepicker which currently it is not supporting.

+1  A: 

See the jQuery UI docs. In code:

.datepicker("getDate");

Returns the current date for the datepicker or null if no date has been selected. I just ran this method on the demo box provided on the jQuery UI docs. Text from firebug console:

[no date set]

>>> $("#datepicker").datepicker("getDate");
null

[I then set the date to tomorrow using the datepicker]

>>> $("#datepicker").datepicker("getDate");
Tue Apr 06 2010 00:00:00 GMT+1200 (New Zealand Standard Time) {}

Is this what you are after?

wiifm
A: 

The daterangepicker is made up of two datepickers that get automatically generated. The start date datepicker has the class "range-start" and the end datepicker has "range-end".

Thus, accessing the getDate functions is pretty straightforward:

$(".range-start").datepicker("getDate");
$(".range-end").datepicker("getDate");

Tested in Firefox, worked for me perfectly. Great plugin btw!

Trafalmadorian