Last active
March 13, 2018 14:37
-
-
Save hans2103/c95efb8f74fcece9da08eac4458fe9f0 to your computer and use it in GitHub Desktop.
Joomla RSForm!Pro customvalidation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('_JEXEC') or die('Restricted access'); | |
require_once dirname(__FILE__) . '/validation.php'; | |
class RSFormProCustomValidations extends RSFormProValidations | |
{ | |
public static function Nederlands_Telefoonnummer($value, $extra = null, $data = null) | |
{ | |
// The following makes sure the submitted value is a Dutch Phone Number | |
if (self::validate_phonenumber($value)) | |
{ | |
// Return true if the validation passed. | |
return true; | |
} | |
else | |
{ | |
// Return false if the validation didn't pass. | |
return false; | |
} | |
} | |
public static function Nederlands_postcode($value, $extra = null, $data = null) | |
{ | |
// The following makes sure the submitted value is a Dutch Postal Code | |
if (self::validate_zipcode($value)) | |
{ | |
// Return true if the validation passed. | |
return true; | |
} | |
else | |
{ | |
// Return false if the validation didn't pass. | |
return false; | |
} | |
} | |
public static function validate_phonenumber($phonenumber) { | |
return preg_match('/(^\+[0-9]{2}|^\+[0-9]{2}\(0\)|^\(\+[0-9]{2}\)\(0\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\-\s]{10}$)/', $phonenumber); | |
} | |
public static function validate_zipcode($zipcode) { | |
return preg_match('/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/', $zipcode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment