skip to content »

Php code for validating email

Each field in the form can have zero, one or more validations.

The first argument is the name of the input field in the form.Simfatic Forms helps you to make complete, feature rich web forms and get it online quickly. This generic PHP form validator script makes it very easy to add validations to your form.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.For example, “req” means required, “alpha” means allow only alphabetic characters and so on.It is very essential to have the input to your form validated before taking the form submission data for further processing.

When there are many fields in the form, the PHP validation script becomes too complex.

Moreover, since you are doing the same or similar validation for most of the forms that you make, just too much of duplicate effort is spent on form validations.

Note: You can make web forms quickly with Simfatic Forms.

The second argument is the validation descriptor that tells the type of the validation required.

The third argument is the error message to be displayed if the validation fails.

class My Validator extends Custom Validator { function Do Validate(&$formars,&$error_hash) { if(stristr($formars['Comments'],' { $error_hash['Comments']="No URLs allowed in comments"; return false; } return true; } } This validation descriptor is for select input items (lists) Normally, the select list boxes will have one item saying ‘Select One’.