regex - PHP regular expression not working properly -
so trying validate phone numbers form xxx-xxx-xxxx x digit. problem having can come in more 4 digits lastly grouping of numbers. see doing wrong? thanks.
$telnumpattern = '/[0-9]{3}-[0-9]{3}-[0-9]{4}/'; //regular look match xxx-xxx-xxxx if(empty($_post['telnum'])) { $errors['telnum'] = "*your telephone number can't empty"; } else if(!preg_match($telnumpattern, $_post['telnum'])) { $errors['telnum'] = "*your email must in form xxx-xxx-xxxx"; }
$telnumpattern = '/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/';
use anchors create exact match.
php regex
No comments:
Post a Comment