datepicker, click event

datepicker, click event

Hello,
I have the code below (datepicker) which works if its within the same file but if its pulled in from an external js file  its wont work. My strength isn't in Jquery or javascript and I'm hoping someone here can help. I have a feeling it has something to do with the click event  but not sure how to implement the event.

  1. $(function()
    {    $("#datepicker").datepicker
         ({  showButtonPanel: true,
            minDate: '0M',
            maxDate: '+90D',
            dateFormat: 'yy-mm-dd',
            showButtonPanel: false
        });
       
        $( "#datepicker" ).change(function()
        {    var myDate = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
            var the_date =  $('#sb_datepicker').val();
            document.getElementById('time').value = myDate;               
        });
    });