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

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item