Restrict user input on a text field.