This is, hands down, the best Javascript form validation tutorial I've ever seen. Granted, it's the only one I've ever seen. But it's fantastic! I sent it around to everyone at work and mandated that we follow these principles everywhere.
http://www.xs4all.nl/~sbpoley/webmatters/formval.html#example
Key points:
1. Javascript validation doesn't ever actually authenticate data -- must always be verified server-side
2. People don't always have JS on, so you must allow the code to degrade gracefully
3. People hate filling out complex forms -- help them out with fast validation and auto-formatting as much as possible
Follow these principles for happy living!