views:

388

answers:

1

I'm looking for an easy to use, reasonably complete form validation solution for php. I recall using one years ago that used a few tags on the HMTL side then captured the OB to replace them with some pretty serious code. This feels slightly like overkill me, yet I'm not REALLY wanting to go nuts with my own right now. I'm using SMARTY, so anything I use should not throw too many curve balls.

I'm going to be validating the basics, name, address, email, credit card number (format validation OK)...

Any ideas? Thanks folks!

+2  A: 

Since you are already using Smarty, you may want to consider the PEAR package HTML_QuickForm (this page says it's being replaced by v2, but that's still in alpha. V1 is pretty solid).

The package allows you to build and process your forms in an easy, straightforward API, and then has a renderer class that works with Smarty. Basically, you can spit out your entire form as an array of objects that Smarty can then render for you. You can control the look and feel with CSS. HTML_QuickForm can be configured to have client-side or server-side validation, or both. You just set up your rules for validation, and it just works. Hope that helps.

Sam McAfee
A concern I have with this is that I need to very closely mirror a set of existing forms that are rather heavily styled. Do you think I would have any problems with this?
Bruce the Hoon