I wrote a tutorial for Web Designer mag a while back that deals with a very similar issue:
http://www.webdesignermag.co.uk/tutorials/add-client-side-form-validation-with-jquery/Not exactly the same as what you're looking for, but close enough to probably answer your question if you ignore the fancy animation stuff.
http://hs-demo.co.uk/forms/ a demo of the tutorial in effect.
hth