add date validation global function