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 ...
https://www.czetsuyatech.com/2021/07/php-us-phone-ip-validator.html
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.
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;
}
Post a Comment