Date Picker linked to different text content

Ok so I have put that code in the page code, and the both the date picker and text box have ID #myDatePicker and #messageText but I get error = newDate.LocaleDateString is not a function