PHP Scripts and Classes

PHP form field validation script

I created this class to get an easy to use form field validation script. Use this class to validate your database inputs or mail forms. Of course there is much more to validate: postcodes, special strings, credit card number etc. In this version is it possible to validate simple text, numbers (with decimals, too), dates, urls, e-mail addresses and for html-tags. Invalid form fields will be reported inside a detailed error message. If all form fields are valid you can use the boolean to submit your form. A new function in version 1.34 is the validation of checkboxes and radio groups.

PHP Script Download - All update information

Visit here Script Demo - Post here your questions and suggestions.

Last changes and updates:

  • Version 1.35
    In this version the date validation is more flexible to accept also day and month numbers without a leading zero. While using the PHP function "checkdate()" there is a additional real date check. Several translations are added now: polish, portuguese and czech. Thank you all for the translations. And at last there was a small bug inside the create_msg method, I used in this version a different function to sort the array.
  • Version 1.34
    A small improvement in the method create_msg() makes it possible to switch between the xhml version and the simple html version. In the fields array one key was named "name", it's renamed to "value" to make it more clear. I removed the variable declarations at the begin of the method validation (thank you Mike Carter for pointing me on this). Because the value of a checkbox (radio) type field is only available if the element is checked there are new functions to validate this elements.
  • Version 1.33
    The regular expression pattern of the check for html code wasn't good, It's working now. The example page is modified to test general text inside a textarea (usefull to test the html code check). There are also spanish translations for the messages now, thank you Mark for doing this job.