Created
February 15, 2024 07:07
-
-
Save Pahom-ka/c4c4f632ba4e6b48ca41711dc7f3576c to your computer and use it in GitHub Desktop.
modx formit russian phone validator for formit
This file contains hidden or 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 | |
$success = false; | |
if (preg_match('/^(\+?7|8)\s?(\(\d{3,5}\)|\d{1,3})\s?\d{1,3}[-\s]?\d{1,3}[-\s]?\d{1,3}$/', $value)) { | |
$success = true; | |
} else { | |
$validator->addError($key, 'Неверный формат номера телефона!'); | |
} | |
return $success; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment