Javascript error preventing datepicker fixed