Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DatePicker: Get Selected Date

I need to be able to grab the selected date from the Datepicker and populate another textbox with the selected value. I am currently using the onClose function like this:

$('#defaultDate').datepicker({
    onClose:function(theDate) {
        $('#txtEntry1').text = theDate;
    }
});
like image 343
Matt Avatar asked Feb 22 '10 14:02

Matt


1 Answers

There's an easier way to do it. Use the built-in alt-field option and you're done.

Populate an alternate field with its own date format whenever a date is selected using the altField and altFormat options. This feature could be used to present a human-friendly date for user selection, while passing a more computer-friendly date through for further processing.

like image 132
Matt Ball Avatar answered Oct 09 '22 18:10

Matt Ball