Reload / Restart Google reCAPTCHA

0

I am making a form to send messages from my website, which I am doing with jquery and ajax , using the reCAPTCHA of Google with the title.

The messages are sent correctly, but the point is that when sending the email the reCAPTCHA is marked as valid , even though I restart the form. I was using the following statement grecaptcha.reload(); but it has no effect.

My code:

 $.ajax({
            beforeSend:function(){
                init_load();
            },
            url: base_url+'site/send_email',
            type:'POST',
            cache:false,
            data: formData,
            success:function(response){

                end_load();

                if(response.trim() === 'success'){
                    $('#form-send-message')[0].reset(this);
                    grecaptcha.reload();
                    end_load_message('Gracias Tu Mensaje Fue Enviado Correctamente');

                }else if(response.trim() === 'error-c'){

                    load_alert('Comprueba que no eres un Robots');

                }else{
                    grecaptcha.reload();
                    load_message_error('Tu Mensaje No Pudo Ser Enviado Intente Nuevamente');
                }

            }

        });
    
asked by José Romero 27.06.2017 в 20:36
source

1 answer

1

You must use the .reset () method of the Google reCAPTCHA.

grecaptcha.reset();

Google Documentation reCAPTCHA:

  

grecaptcha.reset (opt_widget_id   )

     

Resets the reCAPTCHA widget.   opt_widget_id     Optional widget ID, defaults to the first widget created if unspecified.

Translation:

  

Restart the reCAPTCHA widget.
opt_widget_id Optional Widget ID, by default, takes the first widget that was created.

    
answered by 27.06.2017 в 20:41