Functions to validate user input.