MobilePhoneNumber.php 625 B

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