function gb_validate_number in Phone Number 6
Same name and namespace in other branches
- 7 includes/phone.gb.inc \gb_validate_number()
Validate country level phone number.
Parameters
$number: Digits only value.
$ext: Digits only value.
$error: The error message to shown to user. Available parameters to use in the error message are
- "%countrycode": the alpha-2 CC
- "%phone_input": the original number input by user (could be invalid)
- "%max_length": allowed maximum length of the phone number
Return value
boolean TRUE if it is a valid phone number for that country, FALSE otherwise.
1 call to gb_validate_number()
File
- includes/
phone.gb.inc, line 37 - CCK Field for United Kingdom phone numbers.
Code
function gb_validate_number($number, $ext = '', &$error) {
// Don't worry about separators
if (preg_match(_uk_phone_rules(), cck_phone_clean_number($number))) {
return TRUE;
}
// t() is not needed
$error = '"%phone_input" is not a valid United Kingdom phone number, it should be a 10 digit number like "99 9999 9999", with optional leading "0"';
return FALSE;
}