added check to determine which type to display error against for dates element