phone number verification filter

  Awestruck 19:18 13 Aug 2009
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 2009

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 2009

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

  Awestruck 23:05 18 Aug 2009

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

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

Elsewhere on IDG sites

Alienware 17 R4 2017 review

These brilliant Lego posters show just what children's imaginations are capable of

Mac power user tips and hidden tricks

Comment réinitialiser votre PC, ordinateur portable ou tablette Windows ?