How to validate an email address in JavaScript

How to validate an email address in JavaScript

function validateEmail(email) {
    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(String(email).toLowerCase());
}


var ckk = validateEmail("[test@test.com](mailto:test@test.com)")

Leave a Reply

Your email address will not be published. Required fields are marked *