Such type of term/agreement is called "covenant not to compete". It is usually deemed legitimate as long as the terms are reasonable. You should refer to case law/statute in your state to determine whether a specific term is reasonable. The court will balance the employer's interest against employee's interest. The term cannot be too goegraphically and periodically restrained for employee to make a living.