Extracted form validation from PHP demo.