We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message
Contact Forum Editor

Send an email to our Forum Editor:


PLEASE NOTE: Your name is used only to let the Forum Editor know who sent the message. Both your name and email address will not be used for any other purpose.

Tech Helproom


It's free to register, to post a question or to start / join a discussion


 

phone number verification filter


Awestruck

Likes # 0

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

Like this post
OTT_Buzzard

Likes # 0

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!

Like this post
tobyb121

Likes # 0

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

Like this post
Awestruck

Likes # 0

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

Like this post

Reply to this topic

This thread has been locked.



IDG UK Sites

Nokia Lumia 930 review: The flagship Windows Phone 8.1 smartphone

IDG UK Sites

Live Blog: Apple financial results, record June quarter, 35.2m iPhones sold, $37.4b revenue

IDG UK Sites

Welcome to the upgrade cycle - you'll never leave

IDG UK Sites

Why smartphone screens are getting bigger