📜 ⬆️ ⬇️

Phone number

Regular expression for phone number validation:

^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$

Focuses on Russian mobile + city with a code of 3 digits (for example, Moscow).

Green light for:
+79261234567
89261234567
79261234567
+7 926 123 45 67
8 (926) 123-45-67
123-45-67
9261234567
79261234567
(495) 1234567
(495) 123 45 67
89261234567
8-926-123-45-67
8,927 1234,234
8,927 12 12,888
8,927 12,555 12
8 927 123 8 123
')
UPD: thanks to Nutochka , bask and the rest of the discussion: together we found the truth. Let the regular season now become not so critical, but more customers will be able to enter the number.

UPD 2: and a special “thank you” to everyone who lowered my karma. :)

Source: https://habr.com/ru/post/110731/


All Articles