// CREATING THE REQUEST function createRequestObject() { try { xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert('Sorry, but your browser doesn\'t support XMLHttpRequest.'); } return xmlhttp; } var http = createRequestObject(); var sess = createRequestObject(); // IMAGE REFRESHING function refreshimg() { var url = 'includes/image_req.php'; dorefresh(url, displayimg); } function dorefresh(url, callback) { sess.open('POST', 'includes/newsession.php', true); sess.send(null); http.open('POST', url, true); http.onreadystatechange = displayimg; http.send(null); } function displayimg() { if(http.readyState == 4) { var showimage = http.responseText; document.getElementById('captchaimage').innerHTML = showimage; } } // SUBMISSION function check() { if(!validation()) { return false; } var submission = document.getElementById('captcha').value; var url = 'check_captcha.php?captcha=' + submission; docheck(url, displaycheck); } function docheck(url, callback) { http.open('GET', url, true); http.onreadystatechange = displaycheck; http.send(null); } /*//SUBMIT THE FORM, IF THE CAPTCHA IS CORRECT function submitform(){ var name = document.getElementById("contact_name").value; var email = document.getElementById("contact_email").value; var subject = document.getElementById("contact_phone").value; var msg = document.getElementById("contact_comments").value; document.getElementById('loading').style.display = 'block'; document.contact_us.submit.disabled = 'true'; //DISABLE THE SUBMIT BUTTON http.open('GET', 'includes/mailer.php?name=' +name +'&subject=' +subject +'&email=' +email+ '&msg='+escape(msg)); http.onreadystatechange = printit; http.send(null); } //PRINT THE RESPONSE FROM PHP function printit() { if(http.readyState == 4) { document.getElementById('loading').style.display = 'none'; document.getElementById('results').innerHTML = http.responseText; //PRINT THE PHP'S RESPONSE IN THE RESULTS DIV } }*/ function displaycheck() { if(http.readyState == 4) { var showcheck = http.responseText; //alert(showcheck); if(showcheck == '1') //CAPTCHA IS CORRECT { document.getElementById('captcha').style.border = '1px solid #49c24f'; document.getElementById('captcha').style.background = '#bcffbf'; //document.getElementById('captchaerror').innerHTML = ''; document.contact_us.submit(); //submitform(); //SUBMIT THE FORM } if(showcheck == '0') { document.getElementById('captcha').style.border = '1px solid #c24949'; document.getElementById('captcha').style.background = '#ffbcbc'; document.contact_us.captcha.value = ''; //RESET THE CAPTCHA INPUT'S VALUE document.contact_us.captcha.focus(); //CHANGE THE FOCUS TO CAPTCHA INPUT document.getElementById('captchaerror').innerHTML = 'Please Re-enter the CAPTCHA'; } } } // JavaScript Document function validation() { if(document.contact_us.contact_name.value=="") { alert("Please enter the Name"); document.contact_us.contact_name.focus(); return false; } if(document.contact_us.contact_lname.value=="") { alert("Please enter the Last name"); document.contact_us.contact_lname.focus(); return false; } if(document.contact_us.contact_email.value=="") { alert("Please enter the Email"); document.contact_us.contact_email.value=""; document.contact_us.contact_email.focus(); return false; } if(!echeck(document.contact_us.contact_email.value)) { document.contact_us.contact_email.value=""; document.contact_us.contact_email.focus(); return false; } if(document.contact_us.contact_phone.value=="") { alert("Please enter the Phone Number"); document.contact_us.contact_phone.value=""; document.contact_us.contact_phone.focus(); return false; } else if(document.contact_us.contact_phone.value!="") { if(isNaN(document.contact_us.contact_phone.value)) { alert("Only Numbers for Phone"); document.contact_us.contact_phone.value=""; document.contact_us.contact_phone.focus(); return false; } } if(document.contact_us.contact_resume.value=="") { alert("Please enter how did you know SummitResumes us"); document.contact_us.contact_resume.value=""; document.contact_us.contact_resume.focus(); return false; } if(document.contact_us.contact_comments.value=="" || document.contact_us.contact_comments.value=="Enter your query here...") { alert("Please enter the Comments"); document.contact_us.contact_comments.focus(); return false; } return true; } function echeck(Email) { var at=Email.indexOf('@'); var dot=Email.lastIndexOf('.'); var atpos=Email.lastIndexOf('@'); var emlen=Email.length; if (at<1||dot-at<2||atpos+1==emlen||dot+1==emlen||emlen-dot<3) { alert('invalid the Email Address'); return false; } return true; }