var url = 'captchacheck.php?code='; var captchaOK = 2; // 2 - not yet checked, 1 - correct, 0 - failed 
function getHTTPObject() {
 try { req = new XMLHttpRequest(); } catch (err1) { 
 try { req = new ActiveXObject("Msxml12.XMLHTTP"); } 
 catch (err2) { 
 try { req = new ActiveXObject("Microsoft.XMLHTTP"); } 
 catch (err3) 
 { req = false; } 
 } 
 }
 return req; 
 } 
 var http = getHTTPObject(); // We create the HTTP Object 
 function handleHttpResponse() 
 { 
 if (http.readyState == 4) {
 captchaOK = http.responseText; if(captchaOK != 1) { alert('The entered code was not correct. Please try again'); document.ccoptin.code.value=''; 
 document.ccoptin.code.focus(); 
 return false; 
 }
 document.ccoptin.submit(); 
 }
 } 
 function checkcode(thecode) {
  http.open("GET", url + escape(thecode), true);  
  http.onreadystatechange = handleHttpResponse; http.send(null); 
  } 
  function checkform() { // First the normal form validation 
  if(document.ccoptin.Contact0FirstName.value=='') { 
  alert('Please enter the First Name'); 
  document.ccoptin.Contact0FirstName.focus(); 
  return false; 
  } 
  if(document.ccoptin.Contact0LastName.value=='') { 
  alert('Please enter the Last Name'); 
  document.ccoptin.Contact0LastName.focus(); 
  return false; 
  } 
  if(document.ccoptin.Contact0Email.value=='') { 
  alert('Please enter Email ID'); 
  document.ccoptin.Contact0Email.focus(); 
  return false; 
  }   
  
  if(document.ccoptin.code.value=='') { 
  alert('Please enter the string from the displayed image'); 
  document.ccoptin.code.value=''; 
  document.ccoptin.code.focus(); 
  return false; 
  } // Now the Ajax CAPTCHA validation 
  checkcode(document.ccoptin.code.value); 
  return false; 
  }













