Created
February 12, 2017 01:32
-
-
Save asimmittal/3b4d97550759ceb1ef018700238fb773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************* | |
* formatPhoneText | |
* returns a string that is in XXX-XXX-XXXX format | |
*******************************************************/ | |
function formatPhoneText(value){ | |
value = this.replaceAll(value.trim(),"-",""); | |
if(value.length > 3 && value.length <= 6) | |
value = value.slice(0,3) + "-" + value.slice(3); | |
else if(value.length > 6) | |
value = value.slice(0,3) + "-" + value.slice(3,6) + "-" + value.slice(6); | |
return value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment