0 votes
asked in HTML by (4.2k points)
hi all

Validate email address in Javascript?

1 Answer

0 votes
answered by (4k points)

Using Regular Expressions is probably the best way. Here's an example (live demo):

function validateEmail(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\
    return re.test(email);
But keep in mind that one should not rely only upon JavaScript validation. JavaScript can easily be disabled. This should be validated on the server side as well.