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.

Web Design Help


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.



Send to a friend

Email this article to a friend or colleague:


PLEASE NOTE: Your name is used only to let the recipient know who sent the story. Both your name and the recipient's name and address will not be used for any other purpose.