Mobile phone number format Reg-Ex verification

Here in Czech Republic it is every now and then required to use forms including phone numbers for communication with clients or customers. In this case, it really needed to get their contact details as valid and correct, so you can get in touch with them later on. There is a lot of way how to type the phone number. Thus if You do not want to bother your client, it is really needed to make it as easy as possible, so pretty each format of phone number inserted is valid. Especialy if the form field with phone number is mandatory/required for data in form posting.

On the image above is shown the Regular Expression, that can settle the verification of the phone number format in order to confirm it is valid, and meets the previously mentiond local and domain lengths. The code follows in order, to allow copy it for your requirements.Using Regular Expression stated, you can "catch" phone numbers in following format:

  • +420 111 111 111
  • +420 111 11 11 11
  • +420 111111111
  • +420111111111
  • +420 1 1 1 1 1 1 1 1 1
  • 420111111111
  • 420 111 111 111
  • 420 11 11 11 11 1
  • 1 1 1 1 1 1 1 1 1
  • 111 11 11 11
  • 111 111 111
  • 420 1 1 1 1 1 1 1 1 1

^​/​((\+|)(\s\d|\d){9,12})$/g

Code1: Reg-Ex for verification of phone numbers with/without international format covering all numbers to the left.

<input type="tel" id="phone" name="phone" placeholder="+420 123 456 789" pattern="((\+|)(\s\d|\d){9,12})" required oninvalid="this.setCustomValidity('Format incorrect!')">

Code2: usage og Reg-Ex verification in the HTML input field. Please, note the type is NOT text, but tel. The error statement displayed if data inserted does not meet the pattern, can be customized as per your needs.