Answer the question
In order to leave comments, you need to log in
Regular expression to validate phone number in PHP?
Hello,
can you please tell me how to fix this.
if (preg_match('/((8|\+7)-?)?\(?\d{3,5}\)?-?\d{1}-?\d{1}-?\d{1}-?\d{1}-?\d{1}((-?\d{1})?-?\d{1})?/', $login_phone)) {
...
}
Answer the question
In order to leave comments, you need to log in
if (preg_match('/^\+7 \(\d{3}\) \d{3}-\d{2}-\d{2}$/', $login_phone)) {
echo 'ok';
} else {
echo 'wrong number';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question