I am using a date picker from this source http://jqueryui.com/datepicker/#buttonbar , I am trying to let "Today" button on the button bar to be active, can any one help me please.
$(".datepicker").datepicker({
showButtonPanel: true, closeText: 'Clear',
gotoCurrent : true,
changeMonth: true,
changeYear: true,
yearRange: '1900, 2300',
dateFormat: _DateFormatDatePicker,
onSelect: function (dateText, inst) {
dateAsString = dateText; //the first parameter of this function
var dateAsObject = $(this).datepicker('getDate'); //the getDate method
document.getElementById('<%=hdnTempDate.ClientID%>').value = dateText;
}
Try this:
$(".datepicker").datepicker({
showOn: "button",
showButtonPanel: true,
buttonImage: buttonCalendar,
buttonImageOnly: true,
buttonText: ""
});
and call this js code in the pages where you have the calendar.
$.datepicker._gotoToday = function(id) {
$(id).datepicker('setDate', new Date()).datepicker('hide').blur();
};
Try this
$(function() {
$( "#datepicker" ).datepicker({
showButtonPanel: true
});
});
Enable the Buttons panel by: showButtonPanel: true
. Then place the following code after your datepicker JS code:
var _gotoToday = jQuery.datepicker._gotoToday;
jQuery.datepicker._gotoToday = function(a){
var target = jQuery(a);
var inst = this._getInst(target[0]);
_gotoToday.call(this, a);
jQuery.datepicker._selectDate(a, jQuery.datepicker._formatDate(inst,inst.selectedDay, inst.selectedMonth, inst.selectedYear));
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With