Skip to content

Instantly share code, notes, and snippets.

@johnbwoodruff
Created October 6, 2016 21:34
Show Gist options
  • Save johnbwoodruff/8f57f9e24fc4a3457d180b6f8f05ee24 to your computer and use it in GitHub Desktop.
Save johnbwoodruff/8f57f9e24fc4a3457d180b6f8f05ee24 to your computer and use it in GitHub Desktop.
Personal Library
// 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