/**
* verifie si la chaine renseigné est un email
* check if email is valide
* @param string emailAdress
* @return bool
*/
function isEmail(emailAdress){
let regex = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
if (emailAdress.match(regex))
return true;
else
return false;
}
//see https://regexr.com/3e48o for another exemple
//! check email is valid
function checkEmail(email) {
const 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,}))$/;
if (re.test(email.value.trim())) {
console.log('email is valid')
} else {
console.log('email is not valid')
}
}
function Validate (InputEmail){
if (InputEmail.match(/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/)) {
return true;
} else {
return false;
}
}
console.log(Validate("example@gmail.com"));
//Expression
let regex = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
let email = "test.gmail.com"
//Execution
if(email.match(regex)){
console.log("valid")
}else{
console.log("Invalid")
}