The key thing to observe here is that the only changes to the page are to add the script and some CSS. Everything else just piggy-backs on whatever form handling scenario was already in place.
This example uses Prototype.js, but you could substitute jQuery if you swing that way.