Created
March 26, 2017 14:30
-
-
Save lengocgiang/21c24cc71c2f33681c6ee688e8d0676b 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
validateName(name: String) { | |
if (name) { | |
if (/^[A-Za-z0-9][a-z0-9._\-]*$/.exec(name)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
validateEmail(email: String) { | |
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return re.test(email); | |
} | |
validatePassword(password: String) { | |
if (password) { | |
if (password.length < 5) { | |
return false; | |
} | |
if (password === 'Password must be at least 5 characters') { | |
return false; | |
} | |
if (/^[A-Za-z0-9][a-z0-9._\-]*$/.exec(password)) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment