I don't know what kind of code you've written for datepicker. But, here I would like to suggest you to use JQuery with following snippet:
<script type="text/javascript">
$(document).ready(
function() {
$('#input_test').datepicker(
{
onClose: function(dateText, inst) {
alert("My date is: " + dateText);
}
}
);
}
);
</script>
And also, don't forget to include JQuery library file:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
--Amit