Email validating form

01-Aug-2017 21:18

If your callback returns anything other than a boolean TRUE/FALSE it is assumed that the data is your newly processed form data. This is just an example of course, and callbacks aren’t limited to models.

You can use any object/method that accepts the field value as its’ first parameter.

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.

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.

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.

That is a problem when you want to set error messages for them.

Our free email address validator will help you do that in seconds.

To verify the validity of an email address simply enter the email address into the box provided and our "validate email address" tool does the rest.

As shown earlier, the validation array will have this prototype: In order to organize your rules into “sets” requires that you place them into “sub arrays”.

Consider the following example, showing two sets of rules.

To invoke a callback just put the method name in a rule, with “callback_” as the rule prefix.