Email Verification Using JavaScript

Listen Audio
0:00 / 0:00
Email Verification using JavaScript image

Protect fake email 

function validate_email() {

var request;

try {

request= new XMLHttpRequest();

}

catch (tryMicrosoft) {

try {

request= new ActiveXObject("Msxml2.XMLHTTP");
}

catch (otherMicrosoft) 
{
try {
request= new ActiveXObject("Microsoft.XMLHTTP");
}

catch (failed) {
request= null;
}
}
}

var url= "https://www.g3techdesign.com/includes/email_checker.php";
var emailaddress= document.getElementById("enter_email").value;
var vars= "email="+emailaddress;
request.open("POST", url, true);

request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

request.onreadystatechange= function() {
if (request.readyState == 4 && request.status == 200) {
	var return_data=  request.responseText;
	document.getElementById("validate_email").innerHTML= return_data;
}
}

request.send(vars);
}

$(document).ready(function(){
  $('#footer_email').keyup(function(){ 
  var email = $(this).val();
  let regExp = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
  var EmailAvailResult = $('#validate_email');
  if(email.length > 10) {
  if(email.match(regExp)) {
  document.getElementById("footer_email").style.borderColor = "#3c763d"; 
  document.getElementById("footer_email").style.background = "#dff0d8";
  document.getElementById("footer_email").style.color = "#3c763d";
  EmailAvailResult.html('');
  }else{
    document.getElementById("footer_email").style.borderColor = "#e74c3c";
    document.getElementById("footer_email").style.background = "#fceae9";
    document.getElementById("footer_email").style.color = "#a94442";
    EmailAvailResult.html('<span class="errorss"><i class="fas fa-times-circle"></i></span> <font color="red">Please enter a valid email</font>');
}
}else{
    EmailAvailResult.html('<span class="wait">&#9997;</span> Please enter your email address');
}
if(email.length == 0) {
EmailAvailResult.html('');
}
  });
  
$('#enter_email').keyup(function(){ 
  var email = $(this).val();
  let regExp = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
  var EmailAvailResult = $('#validate_email');
  if(email.length > 10) {
  if(email.match(regExp)) {
  document.getElementById("enter_email").style.borderColor = "#3c763d"; 
  document.getElementById("enter_email").style.background = "#dff0d8";
  document.getElementById("enter_email").style.color = "#3c763d";
  EmailAvailResult.html('');
  }else{
    document.getElementById("enter_email").style.borderColor = "#e74c3c";
    document.getElementById("enter_email").style.background = "#fceae9";
    document.getElementById("enter_email").style.color = "#a94442";
    EmailAvailResult.html('<span class="errorss"><i class="fas fa-times-circle"></i></span> <font color="red">Please enter a valid email</font>');
}
}else{
    EmailAvailResult.html('<span class="wait">&#9997;</span> Please enter your email address');
}
if(email.length == 0) {
EmailAvailResult.html('');
}
  });  
  
});

 



Leave a non public comment how to improve it.



Characters Remaining

We are sorry for your bad experience. Leave a non public comment how to improve it.



Characters Remaining

Related Posts (5)

Search text box clear button cover image
add prism code snippet in to a website cover image
using Line Numbers in code snippet   cover image
CHECK FORM VALIDATION without loading a page using AJAX cover image
9th topics cover image

Share this on

Search

Archives

No archives data found yet in 2016.

Find Us on Facebook

Subscribe for new updates



Back to Top