function showSuccesMessage(text) { var x = document.getElementById("errorMessageCaching"); if (text) { $("#errorMessageCaching").text(text); } x.className = "show"; setTimeout(function () { x.className = x.className.replace("show", ""); }, 3000); } // $("#send_success").hide(); $("#send_success").css("display", "none"); $("#send_enquiry").click(function (e) { e.preventDefault(); validateReCaptcha(); var email = $("#email").val(); var name = $("#name").val(); var enqy = $("#enqy").val(); $("#send_enquiry").text("PLEASE WAIT "); // $("#sign_up").append(''); // $("#sign_up").addClass('spinner'); $("#send_enquiry").append( '' ); $(".submitBackground").addClass("submitVisible"); $.ajax({ type: "POST", url: "https://www.pushrcdn.com/authentication/ajax/aboutCheck.php", data: "email="+ email + "&name=" + name + "&enqy=" + enqy, success: function (data) { // $(".submitBackground").removeClass("submitVisible"); // $("#send_enquiryFORM").hide(); // $("#send_success").css("display", "block"); if ( data.indexOf("NAMEEMPTY") > -1 ){ setTimeout(function () { $(".submitBackground").removeClass("submitVisible"); $("#send_enquiry").text("Send enquiry"); $("#theImg").remove(); $("#name").addClass("field-error"); showSuccesMessage('Please enter name'); }, 1000) }else if( data.indexOf("EMAILERROR") > -1){ setTimeout(function () { $(".submitBackground").removeClass("submitVisible"); $("#send_enquiry").text("Send enquiry"); $("#theImg").remove(); $("#email").addClass("field-error"); showSuccesMessage('Please enter valid email'); }, 1000) }else if( data.indexOf("ENQYEMPTY") > -1){ setTimeout(function () { $(".submitBackground").removeClass("submitVisible"); $("#send_enquiry").text("Send enquiry"); $("#theImg").remove(); $("#enqy").addClass("field-error"); showSuccesMessage('Please enter text'); }, 1000) }else if ( validateReCaptcha() != 1){ $(".submitBackground").removeClass("submitVisible"); $("#send_enquiry").text("Send enquiry"); $("#theImg").remove(); $("#enqy").addClass("field-error"); showSuccesMessage("Please validate recaptcha!"); }else{ $.ajax({ type: "POST", url: "https://www.pushrcdn.com/authentication/ajax/mailing.php", data: "email="+ email + "&name=" + name + "&enqy=" + enqy + "&grecaptcha=" + grecaptcha.getResponse(), success: function (data){ $(".submitBackground").removeClass("submitVisible"); $("#send_enquiryFORM").hide(); $("#send_success").css("display", "block"); } }); } } }); }); //RECAPTCHA function recaptchaCallbackAbout(e) { var container = document.getElementById("captcha2"); container.innerHTML = ""; var recaptcha = document.createElement("div"); grecaptcha.render(recaptcha, { sitekey: "6LfNVOEZAAAAAF3nuotvgb0HJU62MoIpT4bBTgSk", theme: "white", size: "normal", hl: "en", tabindex: 2, }); container.appendChild(recaptcha); } function validateReCaptcha() { var response = grecaptcha.getResponse(); if (response.length == 0) { console.log("notValidated"); setTimeout(function () { $("#reCaptchaError").show(); }, 1000); return 0; } else { console.log("validate"); $("#reCaptchaError").hide(); return 1; } }