phone number verification filter

  Awestruck 19:18 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 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 17 Aug 09

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

  Awestruck 23:05 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.

Should I upgrade to Windows 10? Why upgrade to Windows 10? Is Windows 10 good? The pros and cons of!…

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

This Uplifting Animation Celebrates Team GB’s Road to Rio

How to use Apple Music in the UK: Complete guide to Apple Music's features, including new features…