Documentation and Books

Recent site activity

Web Development‎ > ‎JavaScript‎ > ‎

How to check if the entered e-mail address is valid?

This can be done by using a regular expression, below is a sample function that checks if an e-mail address has the correct syntax:

  function checkMail(email){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}

return false;
}