Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Stripping dashes from phone number


rkoechel2004

Recommended Posts

I've been having a few problems with customers putting dashes in their phone number and when I use the automated fedex label contrib Fedex won't make a label because there are dashes in the phone number. If there a way to strip the dashes from a phone number when a customer creates an account?

 

I tried the simple solutions already by limiting the phone number field to 10 spaces and putting a note next to the box telling customers to use this format "3031234567". But a few still don't do it right.

 

Thanks

Ryan

rkoechel2004

Link to comment
Share on other sites

I tried modifying my last post and it ended up going through incomplete. Here is what it should be:

 

I just had a client do a test order and when they hit the Verisign page for credit card processing it told them their phone number was invalid. Turns out they used the format xxx.xxx.xxxx and Verisign apparently can't handle that format. I tried the fix you posted here and substituted the dot for the dash in your code:

 

$telephone = tep_db_prepare_input( ereg_replace(".", "", $HTTP_POST_VARS['telephone']) );

 

Now I am getting an error during the 'create an account' phase that my telephone number must be a minimum of 10 characters. Does the syntax for your fix need to be different when replacing a dot with a space than it is when replacing a dash with a space? I'm not a PHP programmer but know the dot is used for concatenation. Is this causing my problem?

 

Thanks

Link to comment
Share on other sites

Since a dot in regular expressions means "any character" the complete telephone number was erased... You need to put a backslash in front of it. While you are at it, you could delete both dashes and dots by using:

$telephone = tep_db_prepare_input( ereg_replace("\.|-", "", $HTTP_POST_VARS['telephone']) );

So "backslash dot pipe dash" where the pipe character means "OR" in regular expressions.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...