Hello. There is a field to fill in the mobile phone number <input type="tel" name="phone"> , in which you can enter the phone in either the international format (+375111111, +375 111 111, + 375-111-111), or local (8111111, 8 11 11, 8-11-11), i.e. it is allowed to use numbers, space, hyphen and plus, but my check fails - I write:

 <input type="tel" name="phone" value="" size="40" required data-validation-regexp="\+?\(?\d{2,4}\)?[\d\s-]{3,}"> 

Where is the mistake?

  • In regexp, probably. If the text +dddddddd validates +dddddddd , you need to backslash. - Vesper
  • @Vesper not, on +dddddddd also swears ... - Vasya
  • one
  • @stribizhev is good, only there is still left for a person to enter at least 7 digits, and not 5 as it is now - Vasya
  • one
    Please give examples. - Wiktor Stribiżew

1 answer 1

 <input type="tel" name="phone" value="" size="40" pattern="\+?\(?\d{2,4}\)?[\d\s-]{3,}"> 

You need a pattern, not the required data-validation-regexp.

  • Only the pattern itself is probably still wrong - Vasya
  • It seems to be taken from the instructions of Google;) - Visman