Skip to main content

Validate email address JavaScript function.

/**
 * Validates an email address
 *
 * A valid e-mail address is a string that matches the email production of the
 * following ABNF, the character set for which is Unicode. This ABNF implements
 * the extensions described in RFC 1123.
 *
 * https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
 *
 * @param {String} value
 * @return {Boolean}
 */
function isEmail(value) {
    return /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value);
}