Answers for "regular expression for email in js"

46

javascript regex email

function validateEmail (emailAdress)
{
  let regexEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  if (emailAdress.match(regexEmail)) {
    return true; 
  } else {
    return false; 
  }
}

let emailAdress = "[email protected]";
console.log(validateEmail(emailAdress));
Posted by: Guest on March-26-2020
0

regular expresion for email javascript

// onclick function
function validEmail() {
    const regularExpresionForEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    const input = document.getElementById('input')
    const inputValue = input.value;

    if (inputValue.match(regularExpresionForEmail)) {
        const successmsg = document.getElementById('text');
        successmsg.innerHTML = `<p class="text-success">Your Input is Valid</p>`

    } else {
        const msg = document.getElementById('text');
        msg.innerHTML = `<p class="text-danger">Input  Valid charecter! </p>`

    }
    input.value = '';
}
Posted by: Guest on September-08-2021

Code answers related to "regular expression for email in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language