Best solution to tedious form validation?



I've been working on a membership form for a while, and find it very tedious to get an acceptable level of form validation. A web search for solutions revealed some home-brewed solutions, such as these:

http://simonwillison.net/2003/Jun/17/theHolyGrail/
http://samuelsjoberg.com/archive/2004/11/form-validation-on-client-and-server

Quoting from the first link, this is my idea of what form validation is like from the user's perspective:

1. The form is displayed; you fill it in.
2. You submit the form to the server.
3. If you missed something out or provided invalid input, the form is
redisplayed pre-filled with the valid data you already entered.
4. The redisplayed form tells you what you got wrong. It also flags
the fields that were incorrect.
5. Loop until you fill the form in correctly.

In my membership form, I've found this to be complicated, error-prone and tedious if coded by hand in PHP. Plus, I find that very little of the code that comes out of it can be reused. There must be a better way...

I'm all for coding by hand, but in this case, the most productive environment I can imagine would be a WYSIWYG IDE environment, where you draw the form and pick most properties from drop-down lists. The IDE would then generate all the code for you, and offer to FTP it to the right location. I believe this is what Microsoft wanted to accomplish with Web Forms in ASP.NET. The big drawback there (correct me if I'm wrong) is that ASP.NET forms only work on IIS servers and IE clients. Is there anything like ASP.NET Web forms, but less MS-centric, and using PHP code? If not, what's the next best solution?

Many thanks in advance.

Gustaf
.