/ Published in: jQuery
These days when you are using forms you need some sort of protection from bots and spammers.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Validate the Recaptcha' Before continuing with POST ACTION function validateCaptcha() { challengeField = $("input#recaptcha_challenge_field").val(); responseField = $("input#recaptcha_response_field").val(); var html = $.ajax({ type: "POST", url: "../php/validateform.php", data: "form=signup&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField, async: false }).responseText; //console.log( html ); if(html == "success") { //Add the Action to the Form $("form").attr("action", "../php/db-process-form.php"); $("#submit").attr("value", "Submit"); //Indicate a Successful Captcha $("#captcha-status").html("<p class=\"green bold\">Success! Thanks you may now proceed.</p>"); } else { $("#captcha-status").html("<p class=\"red bold\">The security code you entered did not match. Please try again.</p>"); Recaptcha.reload(); } }
URL: http://www.jquery4u.com/forms/setup-user-friendly-captcha-jqueryphp/