How to prevent user to enter a time