Mousa Alsheikh
Senior Full Stack Developer
|
Menu
HOME
BLOG
CAREER
SKILLS
PROJECTS
CONTACT
Blog
How to detect if text contains a telephone number in JavaScript?
09-Dec-2021
1126 Reads
You can use the following JavaScript function to detect if a text contains a telephone number.
function hasPhoneNumber(text){
return text.match(/\d/g) != null && text.match(/\d/g).length >= 10 && text.match(/\d/g).length < 15;
}
regex
detect phone number
javascript
Also on my Blog:
How to detect Barcode Scan in JavaScript
How to generate GUID / UUID in JavaScript?
What is ECMAScript
How to validate Email Address in JavaScript