Return to Snippet

Revision: 44588
at April 14, 2011 16:50 by jquery4u


Initial Code
//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();
    }
}

Initial URL
http://www.jquery4u.com/forms/setup-user-friendly-captcha-jqueryphp/

Initial Description
These days when you are using forms you need some sort of protection from bots and spammers.

Initial Title
Easy Captcha Setup Using jQuery/AJAX/PHP

Initial Tags
php, jquery

Initial Language
jQuery