Refactor datepicker implementation to eliminate DOM manipulation.