“Cara memvalidasi alamat email di JavaScript” Kode Jawaban

Email JavaScript Regex

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));
adriendums

JS Email Regex

function isValidEmail(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,}))$/;
  return re.test(String(email).toLowerCase());
}
Annoying Armadillo

Cara memvalidasi alamat email di JavaScript

function validateEmail(email) 
    {
        var re = /\S+@\S+\.\S+/;
        return re.test(email);
    }
    
console.log(validateEmail('[email protected]'));
Witty Warbler

Email Regex JavaScript

//99.99% Matching..
let emailRegEx = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
The Ultimate Karam

Cara memvalidasi alamat email di JavaScript

function validateEmail(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,}))$/;
    return re.test(String(email).toLowerCase());
}
LedioNase

Cara memvalidasi alamat email di JavaScript

     // Html form call function name at submit button

    <form name="form1" action="#"> 
    <input type='text' name='text1'/>
    <input type="submit" name="submit" value="Submit" 
    onclick="ValidateEmail(document.form1.text1)"/>
   </from>

    // Write the function name ValidateEmail below

    <script>
     function ValidateEmail(inputText)
    {
  var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
    if(inputText.value.match(mailformat))
    {
    alert("Valid email address!");
    document.form1.text1.focus();
    return true;
    }
    else
   {
    alert("You have entered an invalid email address!");
    document.form1.text1.focus();
    return false;
    }
    }
   </script>
Envious Eland

Jawaban yang mirip dengan “Cara memvalidasi alamat email di JavaScript”

Pertanyaan yang mirip dengan “Cara memvalidasi alamat email di JavaScript”

Lebih banyak jawaban terkait untuk “Cara memvalidasi alamat email di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya