On O'Reilly PHP DevCenter this morning, there's a new piece that will make a lot of PHP coders' lives easier - User-Friendly Form Validation with PHP and CSS
One of the more common problems PHP programmers must tackle is that of form data validation. For example, suppose you have a form where users must enter an email address. Using a regular expression, you could test whether the format of the email address is valid before using the email address; if the email address doesn't have a valid format, you can ask the user to re-enter it.
This example is very typical of most of the validation that programmers deal with all the time, and it just gets old after a while. Their suggetion is not to pawn off the data to be validated to another page, but to simply submit the page to itself and do the validation at the top. Then, to combine that with CSS, you simply add a CSS class in your style tag for the error/warning text you want to highlight and use that to alter the form or display a message to notify the user of the error.




