Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function formatPhone(phone) {
- let value = phone
- value = value.replace(/\D/g, '')
- value = value.replace(/^(\d{2})(\d)/g, '($1) $2')
- value = value.replace(/(\d)(\d{4})$/, '$1-$2')
- return value
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement