Email Verification Using JavaScript

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 experiance. Leave a non public comment how to improve it.



Characters Remaining

Related Posts (5)

Search text box clear button image

Search text box clear button

Author image
By JOHN Mon Jun 06, 2022 at 09:04 PM (2 years ago)
Updated On Sun Nov 20, 2022 at 06:36 PM (one year ago)

Read More »
add prism code snippet in to a website image

Add prism code snippet in to a website

Author image
By GETACHEW Fri Oct 08, 2021 at 08:57 AM (3 years ago)
Updated On Fri Nov 04, 2022 at 03:08 PM (2 years ago)

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s used in millions of websites, including some of those you visit daily.

Read More »
using Line Numbers in code snippet   image

Using Line Numbers in code snippet

Author image
By JOHN Thu Oct 07, 2021 at 07:47 PM (3 years ago)
Updated On Fri Nov 04, 2022 at 03:08 PM (2 years ago)

Obviously, this is supposed to work only for code blocks (<pre><code>) and not for inline code.

Read More »
CHECK FORM VALIDATION without loading a page using AJAX image

CHECK FORM VALIDATION without loading a page using AJAX

Author image
By MEWDED Fri Aug 14, 2020 at 03:12 PM (4 years ago)
Updated On Fri Nov 04, 2022 at 03:08 PM (2 years ago)

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page

Read More »
9th topics image

9th topics

Author image
By MEBRATU Sat Jun 20, 2020 at 05:41 PM (4 years ago)
Updated On Fri Nov 04, 2022 at 03:08 PM (2 years ago)

almost there

Read More »

Share this on

Search


Archives

No archives data found yet in 2025.

No archives data found in 2016.

Find Us on Facebook

Subscribe for new updates




Back to Top