Jump to content

intagers only


M.O.S. Studios

Recommended Posts

Of course, is_numeric() will return true for '1.5e-2', '0xAB' and other similar variants, non of which remotely resembles a telephone number.

 

What was wrong with the original response pointing you to http://regexlib.com/REDetails.aspx?regexp_id=607

Link to comment
https://forums.phpfreaks.com/topic/134653-intagers-only/#findComment-701119
Share on other sites

  • 2 months later...

ok i figured it all out

 

this is the new code that only allowes phone numbers, im 100% this works like it is suppost to

 


preg_match('/(^[0-9]*)/i', $_POST['ship_phone1'].$_POST['ship_phone2'].$_POST['ship_phone3'], $matches);
if($_POST['ship_phone1'].$_POST['ship_phone2'].$_POST['ship_phone3'] == $matches[0])
{
  if($_POST['ship_phone1']<="199")
  {$error .="Your Area Code cannot start with 1 and must be 3 digits long.<br>"."\n";}
  if($_POST['ship_phone2']<="199")
  {$error .="Your Phone Number cannot start with 1 and must be 3 digits long.<br>"."\n";}
  if(strlen($_POST['ship_phone3'])!="4")
  {
   $error .="Your Phone Number Must contain 10 digits.<br>"."\n";
  }
}
else
{
  $error .="Your Phone Number Can only contain characters 0-9.<br>"."\n";
}

Link to comment
https://forums.phpfreaks.com/topic/134653-intagers-only/#findComment-755429
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.