This topic is a bit on the old side, but I thought I'd shamelessly plug a library I've been writing for this very purpose. It's not exclusive to HTML forms, but was written with them, at least partially, in mind.
I wasn't feeling very creative when I named it, so "Validator" will have to do for now. Here you go: https://github.com/wilhelm-murdoch/Validator