Hi I am in the process of validating my post data and have come to the phone number field.
I'm not quite sure how to approach this.
When I get to that part of my switch, I send it through the
intval() function. This seems to take of the 0 on the beginning of the string.
I decided to leave it as a string, and then use
settype() just before doing my database stuff.
Here is my code relating to the phone number:
PHP Code:
case "phone":
$num_len = strlen($value);
if(!ctype_digit($value)){
$errors[] = "You can only enter digits into the phone field.";
}
if($num_len != 11){
$errors[] = "Your telephone number must be 11 digits.";
}
die();
break;
I also did a bit of research and found UK landline and mobile numbers contain 11 digits, and the landlines range from 01200 up to 01997 (with the exception of around 50 which are 'not in use' (according to wikipedia)).
Anyone got any suggestions on how to tackle this?
Thank you for any feedback.
Kind regards,
LC.