Reputation: 15925
Is it possible to execute a custom function when a date is selected from the jQuery datepicker?
I have tried using the onClose option, but that just seems to execute the function when the page loads for the first time, after that I can change the date as many times as I want and the function does not execute.
Upvotes: 1
Views: 1129
Reputation: 30565
$( "#datepicker" ).datepicker({
onSelect: function(dateText, obj){
alert(dateText); // Or do something else you need it to do
}
});
I've saved an example in a jsFiddle - http://jsfiddle.net/GZE7D/
Upvotes: 1
Reputation: 14827
You can try running your code in onSelect
function:
$('.datepicker').datepicker({
dateFormat: 'dd-mm-yy',
numberOfMonths: 1,
onSelect: function(selected,evnt) {
// Run your code here
}
});
Upvotes: 0
Reputation: 5822
Try:
$("#id").datepicker({
onSelect: function( date ){
// do stuff
}
});
Upvotes: 1