jQuery: The Write Less, Do More JavaScript Library

Validate + Captcha + Remote

View: New views
2 Messages — Rating Filter:   Alert me  

Validate + Captcha + Remote

by Marco-110 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,
I use captcha to prevent spam in this way (token is a random string
needed to validate user input field)

var token = 'somerandomstring';
$(".myform").validate({
                        rules: {
                                captcha: {
                                        required: true,
                                        remote: "/captcha.php?t="+token
                                }
                        }
});


Now i need to refresh che captcha code, so I call this function:

function newCaptcha()
{
        $.getJSON("/newCaptcha.php", function(data){
                token = data.t;
               // some stuff
        });
}

Why the validator doesn't use the new token?

Re: Validate + Captcha + Remote

by Marco-110 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


up
LightInTheBox - Buy quality products at wholesale price