Two things to start off with: 1) you're looking for a Javascript solution if you want to provide immediate feedback (e.g. without submitting form to the server and then loading a new page), and 2) the most important thing about client-side validation is that you should do the same validations on the server-side as well. Client-side scripting is too easily tampered with and/or disabled and thus can not be trusted.
As for a specific solution, that depends on what your HTML form looks like and what (specific) type of validation(s) you want.