All you have to do is define some validation rules in the file.
There are certain validation rules that are automatically applied to fields of with certain characteristics.
However, there's a great PEAR package that needs a little more exposure: HTML_Quick Form.
It makes handling the rendering and display of forms, and more usefully, both client and server-side validation, quick and easy.
Using HTML_Quick Form2 helps these developers create usable and secure Web forms without sacrificing visual appeal.