Validate user input on typing. Fixes #8.