Created
October 6, 2016 21:34
-
-
Save johnbwoodruff/8f57f9e24fc4a3457d180b6f8f05ee24 to your computer and use it in GitHub Desktop.
Personal Library
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
// As per the RFC2822 standards | |
function isValidEmail(email) { | |
return /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/g.test(email); | |
} | |
// NOTE: This only checks for North American phone numbers | |
// Supports the following formats: 444-555-1234 246.555.8888 1235554567 | |
function isValidPhone(phone) { | |
return /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g.test(phone); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment