PHP Form validation | arfore dot com

Recently I had to build a custom form for VSU’s implementation of R25 by CollegeNet.  The form was designed to allow individuals to schedule an event at VSU using our facilities and equipment.  The form is a multi-part form that branches off at the third page based on prior answers.

One of the hurdles in the form creation was the necessity of validating the form input on a page before proceeding to the next part of the form.  While this fairly routine process can be accomplished by using a self-referencing form and validating the contents of the $_POST superglobal, the number of form elements made it somewhat cumbersome.

Enter the PHP Form Validation Script.  While searching for some ways to make the validation more painless to code, I ran across a nifty PHP script at the HTML Form Guide website.  It is a object-oriented PHP script that make it much easier to do the validation on html form elements.  There are quite a few pre-defined validation descriptors, plus a method that allows for overriding the DoValidate function to create your own custom descriptor.

There is one thing that I would like the script to handle natively:

  1. use of a “pretty” or “friendly” name in the validation error messages, currently it displays the element name

There is also an undocumented validation descriptor in the script.  The pre-defined selone is used for a select/option element.  According to the code the default error message is “Please select an option for %s” and it check to ensure that the value for the element is set and that the value is less than or equal to zero.  If either of those check fail then the error message is displayed.

%d bloggers like this: