My regex of choice is:

/^[\+]?[0-9]{0,3}\W?+[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im

Valid formats:

(123) 456-7890
(123)456-7890
123-456-7890
123.456.7890
1234567890
+31636363634
075-63546725
+1 (415)-555-1212
+1 (123) 456-7890
+1 (123)456-7890
+1 123-456-7890
+1 123.456.7890
+1 1234567890
+1 075-63546725
+12 (415)-555-1212
+12 (123) 456-7890
+12 (123)456-7890
+12 123-456-7890
+12 123.456.7890
+12 1234567890
+123 075-63546725
+123 (415)-555-1212
+123 (123) 456-7890
+123 (123)456-7890
+123 123-456-7890
+123 123.456.7890
+123 1234567890
+123 075-63546725
+1(415)-555-1212
+1(123) 456-7890
+1(123)456-7890
+1123-456-7890
+1123.456.7890
+11234567890
+1075-63546725
+12(415)-555-1212
+12(123) 456-7890
+12(123)456-7890
+12123-456-7890
+12123.456.7890
+121234567890
+123075-63546725
+123(415)-555-1212
+123(123) 456-7890
+123(123)456-7890
+123123-456-7890
+123123.456.7890
+1231234567890
+123075-63546725
Answer from EeeeeK on Stack Overflow
🌐
OutSystems
outsystems.com › forums › discussion › 88524 › phone-number-validation
Phone Number validation | OutSystems
May 24, 2023 - I am doing a reactive web application to store the data of an employee locally (I am not using database .. I am using structures) , while storing the phone number I need to validate it . The phone number should not contain alphabits and special charecters and it should only contain 10 digits .
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Build a Telephone Number Validator
February 23, 2024 - Hey so I finished writing my JS for the Telephone Validator project. Something weird happens and I can’t work out what’s going on… So for a few of the numbers the validation function returns true, but then I run it aga…
Discussions

Form Field Phone Number Validation
TL;DR I'm trying to add a "telephone number" field into a form, is there a component for that, similar to the Email Address? Or is there a dropdown somewhere I'm missing/something easy? If not, how would I do that? So, this may be a newbie question... Is there any easy way to put a "phone number" ... More on community.retool.com
🌐 community.retool.com
1
0
September 23, 2022
Validating phone numbers - worth the trouble?
Do you mean validating just format, or like actually whether it's a valid, working phone number? More on reddit.com
🌐 r/webdev
33
8
February 18, 2022
Phone Number Regular Expression Validation
Howdy I’ve been searching for a decent phone number regular expression validation and it turns out a lot harder to dig one up than I expected. I’ve found plenty, but it turns out that most of them appear on the surface to be fine, but in reality they don’t actually work, like this one: ... More on sitepoint.com
🌐 sitepoint.com
0
October 2, 2005
Telephone Number Validator
Are you sure that’s the correct syntax · Ahhh I see, it runs all the test now but I need to go about this in a different way. It passes all of the ones that should return false and two of the true tests but that doesn’t mean much because I am not accounting for the - or () or spaces · ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
May 29, 2023
Top answer
1 of 16
259

My regex of choice is:

/^[\+]?[0-9]{0,3}\W?+[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im

Valid formats:

(123) 456-7890
(123)456-7890
123-456-7890
123.456.7890
1234567890
+31636363634
075-63546725
+1 (415)-555-1212
+1 (123) 456-7890
+1 (123)456-7890
+1 123-456-7890
+1 123.456.7890
+1 1234567890
+1 075-63546725
+12 (415)-555-1212
+12 (123) 456-7890
+12 (123)456-7890
+12 123-456-7890
+12 123.456.7890
+12 1234567890
+123 075-63546725
+123 (415)-555-1212
+123 (123) 456-7890
+123 (123)456-7890
+123 123-456-7890
+123 123.456.7890
+123 1234567890
+123 075-63546725
+1(415)-555-1212
+1(123) 456-7890
+1(123)456-7890
+1123-456-7890
+1123.456.7890
+11234567890
+1075-63546725
+12(415)-555-1212
+12(123) 456-7890
+12(123)456-7890
+12123-456-7890
+12123.456.7890
+121234567890
+123075-63546725
+123(415)-555-1212
+123(123) 456-7890
+123(123)456-7890
+123123-456-7890
+123123.456.7890
+1231234567890
+123075-63546725
2 of 16
159

First off, your format validator is obviously only appropriate for NANP (country code +1) numbers. Will your application be used by someone with a phone number from outside North America? If so, you don't want to prevent those people from entering a perfectly valid [international] number.

Secondly, your validation is incorrect. NANP numbers take the form NXX NXX XXXX where N is a digit 2-9 and X is a digit 0-9. Additionally, area codes and exchanges may not take the form N11 (end with two ones) to avoid confusion with special services except numbers in a non-geographic area code (800, 888, 877, 866, 855, 900) may have a N11 exchange.

So, your regex will pass the number (123) 123 4566 even though that is not a valid phone number. You can fix that by replacing \d{3} with [2-9]{1}\d{2}.

Finally, I get the feeling you're validating user input in a web browser. Remember that client-side validation is only a convenience you provide to the user; you still need to validate all input (again) on the server.

TL;DR don't use a regular expression to validate complex real-world data like phone numbers or URLs. Use a specialized library.

🌐
Medium
medium.com › @ankitpatidar030 › phone-number-validation-using-google-library-554fe94612ec
Phone Number validation using google library. | by ankit patidar | Medium
March 15, 2024 - For verifying phone number we have a lot of apis and packages available on internet for validating phone number. Here are some of them: 1. AbstractAPI 2. Numverify 3. Numlookup API 4. Neutrino 5. Mocean 6. Vonage 7. BytePlant · But we are not going to work on any of them. Will come to this in next article. Today we will going to look on something which is being provided by google called as libphonenumber-js .
🌐
W3Schools
w3schools.in › javascript › validate-a-phone-number
JavaScript Validate a Phone Number
Learn how to effectively validate 10-digit phone numbers in web forms using JavaScript and HTML with our comprehensive tutorial on JavaScript Phone Number Validation. Discover the practical implementation of regular expressions to ensure accurate and reliable phone number validation.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-validate-phone-numbers-using-javascript
How to Validate Phone Numbers Using JavaScript - GeeksforGeeks
July 23, 2025 - For phone number validation, we'll use Regex to define patterns that match the common formats of phone numbers. By applying different patterns, we can validate phone numbers with or without special characters like parentheses, spaces, or hyphens.
Find elsewhere
🌐
npm
npmjs.com › package › libphonenumber-js
libphonenumber-js - npm
2 weeks ago - This library provides different "metadata" sets, where a "metadata" set is a complete list of phone number parsing and formatting rules for all possible countries. As one may guess, the complete list of those rules is huge, so this library provides a way to optimize bundle size by choosing between max, min, mobile or "custom" metadata: ... You're fine with just validating phone number length via .isPossible() and you don't need to strictly validate phone number digits via .isValid()
      » npm install libphonenumber-js
    
Published   Mar 28, 2026
Version   1.12.41
🌐
npm
npmjs.com › @devmehq › phone-number-validator-js
@devmehq/phone-number-validator-js - npm
November 19, 2025 - Verify phone number, validate format, checking carrier name, geo and timezone infos.. Latest version: 1.6.2, last published: 3 months ago. Start using @devmehq/phone-number-validator-js in your project by running `npm i @devmehq/phone-number-validator-js`. There are no other projects in the npm registry using @devmehq/phone-number-validator-js.
      » npm install @devmehq/phone-number-validator-js
    
Published   Nov 19, 2025
Version   1.6.2
Author   DEV.ME
🌐
W3Resource
w3resource.com › javascript › form › phone-no-validation.php
JavaScript : phone number validation - w3resource
In this page we have discussed how to validate a phone number (in different format) using JavaScript : At first, we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number.
🌐
Reddit
reddit.com › r/webdev › validating phone numbers - worth the trouble?
r/webdev on Reddit: Validating phone numbers - worth the trouble?
February 18, 2022 -

I read a comment the other day that said phone number validation wasn’t worthwhile since it’s a moving target, and I thought it was an interesting opinion. What do you think? Is phone number validation worth it or a waste?

Edit: thank you all for the informed and thoughtful discussion. :)

🌐
Kevinleary
kevinleary.net › blog › validating-real-phone-numbers-javascript
Kevinleary.net: JavaScript Phone Number Validation: Regex & libphonenumber-js
December 8, 2024 - Validate phone numbers in JavaScript using regular expressions and the libphonenumber-js library. This guide covers simple regex, NANP validation, and international numbers.
🌐
SitePoint
sitepoint.com › javascript
Phone Number Regular Expression Validation
October 2, 2005 - Howdy I’ve been searching for a decent phone number regular expression validation and it turns out a lot harder to dig one up than I expected. I’ve found plenty, but it turns out that most of them appear on the surface to be fine, but in reality they don’t actually work, like this one: //Example, try this out for yourself var phoneRegEx = /\\(?\\d{3}\\)?[-\\/\\.\\s]?\\d{3}[-\\/\\.\\s]?/; var string = 'this does not belong here 01 2345 6789'; alert(string.match(phoneRegex)); As you can see, ...
🌐
Twilio
twilio.com › en-us › blog › validate-phone-number-input
How to Validate Phone Number Input in HTML and ...
April 23, 2025 - If you Googled "phone number regex" and regretted it you're in the right place. This post will walk through how to use two free tools to check a phone number's validity using HTML and JavaScript.
🌐
GitHub
github.com › google › libphonenumber
google/libphonenumber: Google's common Java, C++ and ...
Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers. - google/libphonenumber
Starred by 17.9K users
Forked by 2.2K users
Languages   C++ 53.4% | Java 29.9% | JavaScript 15.8% | CMake 0.4% | C 0.2% | Closure Templates 0.1%
🌐
AbstractAPI
abstractapi.com › api guides, tips & tricks › javascript phone number validation
JavaScript Phone Number Validation | Abstract API
1 month ago - For validating international formats: Use a library like libphonenumber-js. For the most accurate results and enriched data: An API like AbstractAPI's Phone Validation is the best choice.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › input › tel
<input type="tel"> - HTML | MDN
elements of type tel are used to let the user enter and edit a telephone number. Unlike and , the input value is not automatically validated to a particular format before the form can be submitted, because formats for telephone numbers vary so much around the world.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Telephone Number Validator
May 29, 2023 - function telephoneCheck(str) { // A phone number must have 10 digits or 11 digits if the first number is a 1 for (let i = 0; i < str.length; i++) { if (str[i] > "0" && str[i] <= "9" && str.length() == 10 || str[i] >…
🌐
AbstractAPI
abstractapi.com › api guides, tips & tricks › 5 ways to validate phone numbers in javascript
5 Ways to Implement Phone Number Validation in JavaScript
1 month ago - HTML5 provides built-in features for form validation with the “input type="tel"” element. This approach leverages the browser's native capabilities to check phone numbers without a separate JavaScript library.
🌐
Reddit
reddit.com › r/webdev › best way to accomplish phone-number validation?
r/webdev on Reddit: Best way to accomplish phone-number validation?
October 20, 2016 -

So initially I had a single, big box to accept a 10-digit phone number. This is a Philippine phone number btw.

Initially I had built this input-mask with keycodes and it used a text input type, so I could block anything except digits and also detect backspace, del key, etc... Then I found out this doesn't work for mobile.

So now I've decided to use three separate boxes. This seems easier as I don't have to do the character counting where I would add dashes after the 3rd and 7th character.

What I'm thinking is using a timeout, it would check to see if there are three digits in the first box, why not use input-type text where you can have maxlength? I'm not preventing non-number characters from being entered.

So, a person could paste a huge string into the number-input field, even after setting a range. Also I hid the up/down arrows. I would bind a paste detection on the cells and it would check to make sure that the specific box didn't have more characters than it allowed and that they were all numbers or throw an error.

Also I found out that my counting was off by one. When you type something into the field, it triggers the count on keydown (should have used key up) so even though there's a character in there, it would think that there was no characters yet. Next time it would be 1 when it should be 2.

edit: I'm also not sure if I'd implement auto-tab.

This seems like a simple thing that I've somehow overblown.