ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

PHP:Form Series, Part 1: Validators & Client-side Validation

(Page 1 out of 3)

Welcome to the first part of a new two-part series on the PHP:Form web component. In this part, I will give you an introduction to PHP:Form, its features, and why it is so useful. I will also discuss the inbuilt validators that PHP:Form supports. In the second part I will discuss the more advanced features of PHP:Form.

What is PHP:Form?

PHP:Form is a (new) web component, developed by TPG PHP Scripts. It is designed to help you create forms with a lot less effort. When you're creating a new PHP script, you will undoubtedly have to create forms to allow input to be entered. There is (almost) no PHP script without forms, and forms usually require solid validation to make sure there are no security leaks. It would be nice if those forms are accessible as well, but this often gets forgotten.

We've all had to create forms again and again. And every time we've had to write those validation functions. I'm sure you remember... if (empty($blah)) { echo 'Invalid'; }, etc. After a while it becomes a really boring and mundane task, and most of the time we don't do it properly either. One of the hardest things to do is to return error messages, indicating what is wrong, and allowing visitors to fix their mistakes, without having to re-do the complete form. I used to simply tell them to hit the back-button, after returning the errors, but this is obviously a not-so-good way of doing it.

Thankfully, that's where PHP:Form steps in. It handles all the boring parts for you, and does it properly as well.

PHP:Form has support for inbuilt validators, which means you only have to use a simple HTML-like syntax to add new validation logic to a form. With these validators also comes automatic client-side validation. All the necessary JavaScript is created for you, and there's nothing you need to do. Another remarkable feature of PHP:Form are so-called "formtypes", which are basically form templates. These allow you define form templates, which can be re-used over and over again.

Let's have a closer look at the validation part of PHP:Form; the validators.

Next: Inbuilt Validators & Client-side Validation »



Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Introduction
  2. Inbuilt Validators & Client-side Validation
  3. Client-Side Validation
Bookmark Article
Download Article
PDF
Download this article as a PDF file