0

Estoy realizando un formulario para envió de mensajes desde mi pagina web, la cual la estoy haciendo con jquery y ajax, usando el reCAPTCHA de Google con índica el titulo.

Los mensaje se envian correctamente, pero la cuestión está en que al enviar el email el reCAPTCHA queda marcado como válido, a pesar de que reinicio el formulario. Estuve utilizando la siguiente instrucción grecaptcha.reload(); pero no tiene ningún efecto.

Mi código:

 $.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');
                }

            }

        });
2
  • Intenta con grecaptcha.reset();
    – Agustin M.
    el 27 jun. 2017 a las 18:39
  • fino me sirvió mucho! gracias! el 27 jun. 2017 a las 18:41

1 respuesta 1

2

Debes utilizar el método .reset() del Google reCAPTCHA.

grecaptcha.reset();

Documentación de Google reCAPTCHA:

grecaptcha.reset(opt_widget_id )

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

Traducción:

Reinicia el widget de reCAPTCHA.
opt_widget_id Opcional ID del widget, por predefinido toma el primer widget que se creó.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.