开发者

getting date from JQueryUI Datepicker

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 dat开发者_开发技巧e. 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.


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?


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜