There are numerous rules available which you can read about in the validation reference.In the above example, we are “trimming” the fields, checking for length where necessary and making sure that both password fields match.

Since you haven’t told the Form Validation class to validate anything yet, it returns FALSE (boolean false) by default.

``The run()`` method only returns TRUE if it has successfully applied your rules without any of them failing. This method initializes the validation class and loads the form helper and URL helper used by your view files. Based on whether the validation was successful it either presents the form or the success page.

For example, let’s say you have a controller named Member and a method named signup.

You can change the validation for a form field only if you are on a Gold plan or higher.

For example, if you need to run a database query to see if the user is choosing a unique username, you can create a callback method that does that. In your controller, change the “username” rule to this: Reload your form and submit it with the word “test” as the username.

You can see that the form field data was passed to your callback method for you to process.

If your form requires even more complex field validation, contact us and we’ll help you get it done.

In this case, select Custom in the Field Validation dropdown list and paste the code above in the input box.

We’ve arbitrarily called these two rules “signup” and “email”.

You can name your rules anything you want: An alternate (and more automatic) method of calling a rule group is to name it according to the controller class/method you intend to use it with.

To store your validation rules, simply create a file named form_in your application/config/ folder.