You are here

function valid_phone_number in Phone 6

Same name and namespace in other branches
  1. 5 phone.module \valid_phone_number()
  2. 7 phone.module \valid_phone_number()

Verification for Phone Numbers.

Parameters

string $countrycode:

string $phonenumber:

Return value

boolean Returns boolean FALSE if the phone number is not valid.

39 calls to valid_phone_number()
AUPhoneNumberTestCase::testPhoneAUInvalid in tests/phone-au.test
AUPhoneNumberTestCase::testPhoneAUValid in tests/phone-au.test
BEPhoneNumberTestCase::testPhoneBEInvalid in tests/phone-be.test
BEPhoneNumberTestCase::testPhoneBEValid in tests/phone-be.test
BRPhoneNumberTestCase::testPhoneBRInvalid in tests/phone-br.test

... See full list

File

./phone.module, line 929
Defines phone number fields for CCK. Provide some verifications on the phone numbers

Code

function valid_phone_number($countrycode, $phonenumber) {
  $countrycode = trim($countrycode);
  $phonenumber = trim($phonenumber);
  if (phone_supported_countrycode($countrycode)) {

    //drupal_set_message('langue = ' . $countrycode, 'error');
    $valid_phone_function = 'valid_' . $countrycode . '_phone_number';
    module_load_include('inc', 'phone', 'phone.' . $countrycode);
    if (function_exists($valid_phone_function)) {
      return $valid_phone_function($phonenumber);
    }
    else {
      return FALSE;
    }
  }
  else {

    //Country not taken into account yet
    return FALSE;
  }
}