How to validate email address in JavaScript?

The best way is using regular expressions.
Example ↓

<script type="text/javascript">
function isValidEmail(email) {
    var regex_pattern = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regex_pattern.test(email);
}
</script>

Also you can use some another reg.exps:

Match 99.99% of all email addresses in actual use today:

    var regex_pattern = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)$/i;

This regex filters dummy email addresses like qwerty@wrwer.rter.
You will need to update it as new top-level domains are added.

var regex_pattern = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\b?)$/i;