Javascript email validation

I’m using regular expression email validation in Javascript.

I’m using the function listed below.

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(email);

It is suitable for a variety of email validation scenarios. Assume, for example,

validateEmail('m@s'); // return false

However, if I attempt to validate something like

validateEmail(''); // return true

Which is correct according to the regular expression in this illustration.

What I need is for it to validate the text “com” before and after “.”, such that the two texts are not the same.

Any assistance would be much appreciated… :slight_smile: