make sure the date if valid befor setting the element