jQuery datepicker, onSelect won't work

Tommy Jakobsen picture Tommy Jakobsen · May 20, 2009 · Viewed 210.3k times · Source

I can't get onSelect working on my jQuery datepicker.

Heres my code:

<script type="text/javascript">
$(function() {
    $('.date-pick').datePicker( {
        onSelect: function(date) {
            alert(date)
        },
        selectWeek: true,
        inline: true,
        startDate: '01/01/2000',
        firstDay: 1,
    });
});
</script>

It's like it doesn't register the onSelect function. What am I doing wrong?

Answer

Antony Carthy picture Antony Carthy · May 20, 2009

No comma after the last property.

Semicolon after alert(date);

Case on datepicker (not datePicker)

Check your other uppercase / lowercase for the properties.

$(function() {
    $('.date-pick').datepicker( {
        onSelect: function(date) {
            alert(date);
        },
        selectWeek: true,
        inline: true,
        startDate: '01/01/2000',
        firstDay: 1
    });
});