function CC_validate_number in Phone Number 7
Same name and namespace in other branches
- 6 includes/API.php \CC_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 (check_plain'ed)
- "%phone_input": the original number input by user (check_plain'ed)
- "%min_length": allowed minimum length of the phone number
- "%max_length": allowed maximum length of the phone number
- "%ext_input": the original extension input by user (check_plain'ed)
- "%ext_max_length": allowed maximum length of the phone extension
Return value
boolean TRUE if it is a valid phone number for that country, FALSE otherwise.
File
- includes/
API.php, line 89 - Phone Number custom country API
Code
function CC_validate_number($number, $ext = '', &$error) {
// Don't need to check for extension because it has been checked by generic validation as all digits, unless has special format/requirements
// your validation
if (FALSE) {
// t() is no needed
$error = '"%phone_input" is not a valid North American phone number, it should be a 10 digit number like "999 999 9999"';
return FALSE;
}
return TRUE;
}