no

Implement Us Phone and Zip Expression Validator in Php

I want a format: a.) phone: (xxx)-(xxx)-(xxxx) b.) zip: (xxxxx)-(xxxx); -(xxxx) is optional But, I couldn't find them so I created ...

I want a format:

a.) phone: (xxx)-(xxx)-(xxxx)
b.) zip: (xxxxx)-(xxxx); -(xxxx) is optional

But, I couldn't find them so I created mine anyway.


$us_phone = "^(\()[0-9]{3}(\))(\-)(\()[0-9]{3}(\))(\-)(\()[0-9]{4}(\))$";
$us_zip = "^((\()[0-9]{5}(\)))(-(\()[0-9]{4}(\)))?$";

$code = $us_phone;

function validate($code, $value) {
if(ereg($validator, $value)) {
return true;
else
return false;
}

Related

php 4573471450312970918

Post a Comment Default Comments

item