C
C
Cheizer2020-04-14 14:30:00
HTML
Cheizer, 2020-04-14 14:30:00

How to correctly set pattern in inpuy type tel?

Please tell me how to set the pattern correctly in the input form.

Now so

<input type="tel" name="Phone"  value="" placeholder="Ваш телефон *" pattern="[0-9]*">


But with this pattern, the form is not sent if you enter a phone number through +7, it is also not sent if you enter a number with brackets 1(222)44444444 or spaces.
JS mask libraries do not want to use.
The question is how to add an option other than numbers, spaces, + and brackets?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2020-04-14
@Cheizer

Keep in the pattern put this check

^(\+7|7|8)?[\s\-]?\(?[489][0-9]{2}\)?[\s\-]?[0-9]{3}[\s\-]?[0-9]{2}[\s\-]?[0-9]{2}$

For every fireman.
https://www.regextester.com/99415
https://www.regexpal.com/94215

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question