phone number verification filter

  Awestruck 19:18 PM 13 Aug 09
Locked

In my PHP form handler I use this filter

//CHECK THAT NO TEXT HAS BEEN ENTERED IN THE PHONE FIELD
if (!is_numeric($phone)){
header ("Location: $errorphoneurl");
exit ;
}

However, many people tend to include spaces, how can my filter also accept spaces?

Regards

Awestruck

  OTT_Buzzard 02:23 AM 14 Aug 09

I can't give an exact answer (i've only recently started learning PHP myself!), but click here looks like it should do what you want...search for "blank" strings and replace with nothing.

hope it works for you!

  tobyb121 22:01 PM 17 Aug 09

remove all the spaces with:
$phone=str_replace(' ',',$phone);

  Awestruck 23:05 PM 18 Aug 09

OTT_Buzzard your suggestion was not suitable but it showed me an excellent PHP resource. Thank you.

tobyb121, your suggestion did the trick. Many thanks.

Best wishes
Awestruck

Advertisement

This thread is now locked and can not be replied to.

How to get Windows 10 now: how to download and install Windows 10 even if GWX.exe is missing

1995-2015: How technology has changed the world in 20 years

Nokia rolls out spherical camera for virtual reality apps

OS X Yosemite vs Windows 10: The Mac and PC operating systems go head to head UPDATED