Format mobile number to this format "(845) 963-2545" #mobileFormat
// format phone number into foreign format
default no:8459632545 format to = (845) 963-2545
// if mobile values is = 8459632545
export const numberFormat = (value) => {
if (value && value !== "") {
let mobile = value.trim()
const first = mobile.substr(0, 3)
const second = mobile.substr(3, 3)
const last = mobile.substr(6, 4)
const number = (`(${first}) ${second}-${last}`)
return number
} else {
return ""
}
}
expected output is = (845) 963-2545
Comments
Post a Comment