Custom validation rules

RSForm! Pro allows to add custom validation rules for the fields that allow validation rules.

Since version 1.51.0, RSForm!Pro allows you to add custom validation rules without modifying the validation.php file. In order to add a new validation rule you will have to create a customvalidation.php file under the following location:


Using this file you will have to create a class that extends the "RSFormProValidations" class as in the following example:

defined( '_JEXEC' ) or die( 'Restricted access' );
require_once dirname(__FILE__).'/validation.php';
class RSFormProCustomValidations extends RSFormProValidations
  public static function validationTest($value, $extra = null, $data = null)
    // The following makes sure the submitted value is "test"
    if ($value == 'test')
      // Return true if the validation passed.
      return true;
      // Return false if the validation didn't pass.
      return false;
  1. The name of the function will be the name of the validation rule, as displayed when choosing it from the Validation Rule area.
  2. On success, the function should return true. On failure, the function should return false. So, if you want to fail validation, just return false.

Variables being used:
$value - Actual value being sent (ie. the value submitted in the form)
$extra - Unused
$data - An array of field properties (eg. $data['NAME'] will return the name of the field)

the "Birthday Field" also provides some specific date related validation rules, which can be further extended in a similar manner:
- the datevalidation.php file which is located under the same path, can be extended by creating a new customdatevalidation.php file.
- following the above code example, you'll only need to replace:
a) /validation.php with /datevalidation.php
b) class RSFormProCustomValidations extends RSFormProValidations with class RSFormProCustomDateValidations extends RSFormProDateValidations

13 persons found this article helpful.

Was this article helpful?

Yes No
Sorry about that

You Should Also Read

Custom PHP code HOT

Display PHP variables by default when form is shown HOT

PHP Scripts HOT

Controlling the calendar HOT

How can I prevent the user from selecting a date in the calendar field HOT