function validateEmail(email) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/;
return emailReg.test(email);
}

Usage:-

if(validateEmail(emailString)){
   alert('Your email is valid');
}
else{
  alert('Your email is not valid! There should be atleast @ and one dot(.) present in it');
}

By admin

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.