Because validation is a process comprised of two parts: syntax and existence, I'll divide the discussion into these two components.I'll then conclude the tutorial by assembling both processes, and offering a few examples.
The third argument is the error message to be displayed if the validation fails.
This validation descriptor is for select input items (lists) Normally, the select list boxes will have one item saying ‘Select One’.
Email addresses: easy to create, difficult to type. Note that FILTER_VALIDATE_EMAIL will validate email addresses that contain domains and top-level domains that do not exist.
Fortunately, PHP (5 and later) comes with a handy set of functions and filters that make testing for email address validity a snap.
We create and associate a set of “validation descriptors” with each element in the form.
The “validation descriptor” is a string specifying the type of validation to be performed.
Nonetheless, to be sure there are times when the provision of a valid email address is an absolute necessity, not only for the site operator but also for the user.
For example, it is often in the interests of both parties that a confirmation email is sent to a specific address whenever goods are purchased from the site.
The first argument is the name of the input field in the form.
The second argument is the validation descriptor that tells the type of the validation required.
For example, “req” means required, “alpha” means allow only alphabetic characters and so on.