Form handler and validator

Form handler and validator

Released 7 years ago , Last update 7 years ago

Validate and filter forms with this PHP class using simple validation rules

This PHP class provides a simple interface to validate and escape form inputs. Returns errors as a PHP array ready for formatting in your scripts.

The form validator supports the following field types:

  • input (text, checkbox, radio)
  • select
  • textarea

And offers the following validation rules:

  • notNULL (is value is empty)
  • notZERO (is value equals to 0)
  • minLen (check for minimum string length)
  • maxLen (check for maximum string length)
  • numeric (is value numeric
  • email (is value a valid Email address)

The class also optionally cleans and escapes user input, to prevent attacks such XSS.

Try the demo to see it action.

Example code:

// Pass the $_POST data into the form class
$form = new Form($_POST);

// Adding a variety of filters
$form->toValidate('firm', 'notNULL;maxLen:200');
$form->toValidate('category', 'select;notZERO');
$form->toValidate('type', 'radio;notNULL');
$form->toValidate('tel', 'notNULL;numeric;maxLen:50');
$form->toValidate('email', 'notNULL;maxLen:200;email');
$form->toValidate('accept', 'checkbox;notNULL');

//Validate rules
$validationResult = $form->validate();

//Did form pass validation?
if ($validationResult) {
    $values = $form -> allValues();
    //Use values in your application!

} else {
    $errors = $form -> errors;
    //Display errors
}

Pricing

14 day 14-day money-back guarantee

$6.99

Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

1 license From » $6.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
No comments have been posted yet.