Created
May 10, 2019 09:50
-
-
Save richardprice-1990/32b0e5ea92e5dd45f28b1c7cc4764ad0 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
async mobileValidation(){ | |
try{ | |
//Mobile format +447XXXXXXXXX | |
let regex_format = /^((44)7\d{9})$/ | |
let mobile = this.mobile | |
if (!mobile) { | |
this.mobile = ""; | |
return | |
} | |
mobile = mobile.replace(/ /g, ""); | |
if (siteConfig[this.site].mobileRegex) { | |
regex_format = siteConfig[this.site].mobileRegex | |
} else { | |
//UK Numbers (attempt to fix) | |
if (mobile.length == 11 && mobile.substring(0, 1) == 0) { | |
mobile = `44${mobile.substring(1)}` | |
} | |
if (mobile.substring(0, 1) == "+") { | |
mobile = mobile.substring(1) | |
} | |
} | |
if (regex_format.test(mobile)) { | |
this.mobile = mobile | |
} else{ | |
this.mobile = "" | |
} | |
}catch(e){ | |
throw(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment