Created
December 10, 2018 16:21
-
-
Save tonysaffo/5ea4f3dfb2ebe436b4fbc9c29a5d6e36 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
_isNumber = (n) => { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
adaptPhone = (val) => { | |
const deleteLastChar = (val) =>{ | |
val = val.substring(0, val.length - 1); | |
if(val[0] != '+'){ | |
val = '+7'+val; | |
} | |
return val; | |
} | |
if (val[0]!='+' && val.length == 1){ | |
val = '+7' | |
} | |
if(!this._isNumber(val)||val.length>12){ | |
return deleteLastChar(val) | |
} | |
return val | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment