smourph
3/24/2016 - 5:17 PM

Check if the mail adress format is correct

Check if the mail adress format is correct

/**
 * Check if the mail adress format is correct
 * @param str
 * @returns boolean
 */
function isMailAdress(str) {
    //var pattern = /^(.*)@(.*)\.(.*)$/i;
    var pattern = /^([-\w~!$%^&*_=+}{\'?]+(?:\.[-\w~!$%^&*_=+}{\'?]+)*)@((?:[\w_][-\w_]*)(?:\.[-\w_]+)*)\.([\w]{2,}?)$/i;
    return pattern.test(str);
}