-
Book Overview & Buying
-
Table Of Contents
CodeIgniter 2 Cookbook
By :
Validating user input allows you to set rules against which input coming in from the user can be judged. For example, you may wish to enforce certain conditions on an e-mail field, most obviously checking for a valid e-mail syntax, but also the minimum and maximum length, and whether it is required. CodeIgniter can even look into a database and check for duplicate values. In this recipe, we're going to build a controller and view, which together will allow the user to input data and have it validated against rules that will be set; errors, if any, will be reported back to the user.
You'll need to be aware of a few things before getting started. The following is a table of all available CodeIgniter validation rules:
|
Rule |
Parameter |
Description |
|---|---|---|
|
required |
No |
It specifies if the specific form element must have data when submitted by the user. It will return |
|
matches |
Yes |
It compares the data between two form elements to see if they match... |
Change the font size
Change margin width
Change background colour