Javascript String isEmail()

Description

Javascript String isEmail()


String.prototype.isEmail = function(){
  var result = false;
  if (this) {/*from w  w w.j  a  v a2s  . c o  m*/
      result = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this);
  }
  return result;
}

Javascript String isEmail()

String.prototype.isEmail = function() {
 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(this);
}

Javascript String isEmail()

let regs = {/*from   w  w w  .  j ava2  s. c o  m*/
    number: /^[0 - 9] * $/,
    email: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
    phone: /^0*(13|14|15|17|18)\d{9}$/,
};

String.prototype.isEmail = function () {
    return regs.email.test(this);
}

String.prototype.isPhone = function () {
    return regs.phone.test(this)
}

module.exports = regs;

Javascript String IsEmail()

String.prototype.IsEmail = function () {
    if (this.match(/^[a-z0-9](\.?[a-z0-9_-]){0,}@[a-z0-9-]+\.([a-z]{1,6}\.)?[a-z]{2,6}$/)) {
        return true;
    }//  w  w  w. j  ava  2  s  . co m

    return false;
}

Javascript String isEmail()

String.prototype.isEmail = function() {
  var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  return re.test(this);
};



PreviousNext

Related