javascript function to format phone number
function formatPhoneNumber(phoneNumberString) {
var cleaned = ('' + phoneNumberString).replace(/\D/g, '')
var match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/)
if (match) {
return '(' + match[1] + ') ' + match[2] + '-' + match[3]
}
return null
}
Also in JavaScript:
- FizzBuzz
- how to sort array least to greatest javascript stACK
- javascript for loop starting from end
- onswitch from tab do something jquery
- adding event listener keypress event in javascript
- how to change the font family using jquery
- string concatenation in js
- hide element js
- Upload image via ajax (jquery)
- bcrypt_lib.node not found
- react cheat sheets
- materialize for react
- ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js): Error: ENOENT: no such file or directory, scandir
- javascript get element width and height
- javascript recursive function for fibonacci series
- Exception in thread "main" org.openqa.selenium.JavascriptException: cannot read getPlayerState
- how to check the listeners on an object js
- count word and space in text javascript
- javascript string single or double quotes
- angular [routerlink]
- emotion.sh keyframes
- isPrototypeOf js
- query selector click event
- javascript number to string