You are here

function valid_phone_number in Phone 5

Same name and namespace in other branches
  1. 6 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.

1 call to valid_phone_number()
phone_widget in ./phone.module
Implementation of hook_widget().

File

./phone.module, line 239
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 ($countrycode == 'fr' || $countrycode == 'it' || $countrycode == 'ca' || $countrycode == 'uk' || $countrycode == 'ru') {

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

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