Skip to content

Instantly share code, notes, and snippets.

@manhlinhng
Created April 18, 2019 07:42
Show Gist options
  • Save manhlinhng/e4fa45238a089fdc88d9953b95406fb7 to your computer and use it in GitHub Desktop.
Save manhlinhng/e4fa45238a089fdc88d9953b95406fb7 to your computer and use it in GitHub Desktop.
function validateEmail(email){
var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return emailReg.test(email);
}
function validatePhone(phone){
var phoneReg = new RegExp(/((09|03|07|08|05)+([0-9]{8})\b)/g);
return phoneReg.test(phone);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment