I've recently melded a few things together to create a better contact form with two types of validation. Pre-validation occurs with javascript as the user enters data so users have an indication that they have input invalid data. The second validation occurs via PHP on submission of the form. You can check it out here: http://www.minc.info/formtest/
I used the FormProcessor.class.php file from Simon Willison's excellent "Easier form validation with PHP" script which I modified slightly (modified file available here: http://www.minc.info/formtest/FormProcessor.class.phps). The javascript validation is done using a modified version of Stephen Poley's excellent Javascript form validation script: http://www.xs4all.nl/~sbpoley/webmatters/formval.html. The modified version is available here: http://www.minc.info/formtest/formval.js . And of course, the php file that runs everything can be viewed here: http://www.minc.info/formtest/index.phps
This is a great combination of a both server-side an client-side validation and was just the kind of thing I was looking for. I’ve downloaded the scripts to try it out and the Javascript validation works fine but when I click the submit button the server-side validation seems to be left out and it just clears the form.
Any ideas why that would be happening?
I’ve put FormProcessor.php, formval.js, and index.php all in the same directory together.
Ian,
You can try downloading the actual files that I used here: http://www.ben-huddleston.com/formtest/phpform.zip