MobilePhoneNumber.php 639 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Abstract base class for QuickForm validation rules.
  5. */
  6. /**
  7. * Validate telephones.
  8. */
  9. class HTML_QuickForm_Rule_Mobile_Phone_Number extends HTML_QuickForm_Rule
  10. {
  11. /**
  12. * Validates mobile phone number.
  13. *
  14. * @param string Mobile phone number to be validated
  15. * @param string Not using it. Just to respect the declaration
  16. *
  17. * @return bool returns true if valid, false otherwise
  18. */
  19. public function validate($mobilePhoneNumber, $options = null)
  20. {
  21. $rule = "/^\d{11}$/";
  22. return preg_match($rule, $mobilePhoneNumber);
  23. }
  24. }