How to Validate Form Data on the Client Side
See also Form Auto Validate, a library solving 90% of your validation needs.
PLEASE UNDERSTAND: Client-side validation is never a full solution, but rather only a convenience that must be used in addition to proper server-side validation. Everything on the client-side should be treated as untrusted and potentially tainted.