Build a form with validation

How to build a form that validates input.