How can I validate UK telephone numbers? I copied the answer from this site, but this answer only accept mobile number. I want to accept both landline and mobile number. Is it possible?
# @reference: http://stackoverflow.com/questions/8099177/validating-uk-phone-numbers-in-php
$telephone = "01752311149"; // not ok.
$telephone = "07742055388"; // ok.
$pattern = "/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/";
if (!preg_match($pattern, $telephone))
{
$error = true;
$message.='<error elementid="telephone" message="invalid" />';
}
I have tried with this regex below but it doesn't work at all,
#http://stackoverflow.com/questions/14512810/regular-expression-mobile-and-landline-number
$pattern = "/^\(0\d{1,2}\)\d{3}-\d{4}$/";