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
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.

🌐
npm
npmjs.com › package › libphonenumber-js
libphonenumber-js - npm
3 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
Discussions

html - Validating Phone Numbers Using Javascript - Stack Overflow
I'm working on a web form with several fields and a submit button. When the button is clicked, I have to verify that the required text boxes have been filled in and that the phone number is in the More on stackoverflow.com
🌐 stackoverflow.com
US Phone Number Validation - Help Needed
I got a regex from Stack Overflow for phone number validation, but it doesn’t get all of the tests to pass. The test results are: telephoneCheck("1 555-555-5555") should return true. telephoneCheck("1 (555) 555-5555") should return true. telephoneCheck("1(555)555-5555") should return true. ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
July 26, 2020
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
Vue Phone Number Input - A phone number input made with Vue.js

Looks good. But I think it's weird that I cant enter a country code myself. I have to scroll down and look for the country my self. Think it would be nice to have. Maybe being able to search in the list.

More on reddit.com
🌐 r/vuejs
3
3
February 1, 2019
🌐
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.
🌐
W3Schools
w3schools.in › javascript › validate-a-phone-number
JavaScript Phone Number Validation - W3Schools
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.
🌐
Javascript-coder
javascript-coder.com › form-validation › javascript-form-validation-phone-number
JavaScript Form Validation - Phone Numbers | JavaScript Coder
This will validate; However, if you want to display a custom error message, you will have to add a little custom Javascript · var phone_input = document.getElementById("myform_phone"); phone_input.addEventListener('input', () => { phone_input.setCustomValidity(''); phone_input.checkValidity(); }); phone_input.addEventListener('invalid', () => { if(phone_input.value === '') { phone_input.setCustomValidity('Enter phone number!'); } else { phone_input.setCustomValidity('Enter phone number in this format: 123-456-7890'); } });
🌐
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.
🌐
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.
Find elsewhere
🌐
Twilio
twilio.com › en-us › blog › validate-phone-number-input
How to Validate Phone Number Input in HTML and JavaScript | Twilio
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.
🌐
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.
🌐
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
🌐
Stack Abuse
stackabuse.com › validate-phone-numbers-in-javascript-with-regular-expressions
Validate Phone Numbers in JavaScript with Regular Expressions
June 7, 2023 - Excluding the country code, combining the remaining parts results in a ten-digit phone number where the area code and the telephone prefix are three digits each, and the line number is four digits. Let's now move into writing a JavaScript function that validates a phone number based on these criteria using regular expressions.
🌐
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.
🌐
Voximplant
voximplant.com › blog › javascript-regular-expression-for-phone-number-verification
JavaScript Regular Expression for Phone Number ...
The Libphonenumber-js library can format, parse, and validate international telephone numbers using the following scripts: getNumberType – Determines the type of a valid phone number.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
US Phone Number Validation - Help Needed - JavaScript
July 26, 2020 - I got a regex from Stack Overflow for phone number validation, but it doesn’t get all of the tests to pass. The test results are: telephoneCheck("1 555-555-5555") should return true. telephoneCheck("1 (555) 555-5555") …
🌐
GitHub
github.com › google › libphonenumber
GitHub - google/libphonenumber: Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers. · GitHub
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%
🌐
GitHub
github.com › abstractapi › javascript-phone-validation
GitHub - abstractapi/javascript-phone-validation: Javascript library for Abstract's Phone Validation API (free)
You can install javascript-phone-validation via npm, from our CDN, or download the source into your project. ... import {AbstractPhoneValidation} from 'javascript-phone-validation' AbstractPhoneValidation.configure('API_KEY') You can have the ...
Author   abstractapi
🌐
DEV Community
dev.to › rthefounding › checking-if-telephone-number-is-valid-4iop
Validating Phone Numbers with JavaScript - DEV Community
September 2, 2021 - // 6. $ end of the string function numberCheck(str) { const regex = /^(1\s?)?(\d{3}|\(\d{3}\))[\s\-]?\d{3}[\s\-]?\d{4}$/ return regex.test(str) } numberCheck("1 555-555-5555"); will display true
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › input › tel
<input type="tel"> - HTML - MDN Web Docs
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.
🌐
Kevin Chisholm
blog.kevinchisholm.com › javascript › javascript-e164-phone-number-validation
Javascript E164 Phone Number Validation | Kevin Chisholm - Blog
February 10, 2021 - The easiest way to perform JavaScript E164 phone number validation is with an ordinary function that contains a regular expression and a test statement. We’ll call our function validatePhoneForE164 and it will pass a variable named phoneNumber ...