Skip to content

ReCaptcha Ajax validation #520

@srakl

Description

@srakl

Hi,

How do i get the recaptcha to validate when submitting a form with ajax? this is my current jquery

<script>
                $(document).on("submit", "#<?= $model->formName() ?>", function () {
                    event.preventDefault();
                    event.stopImmediatePropagation(); 
                    var $form = $(this);
                    $.ajax({
                        "type":"POST",
                        "url":$form.attr('action'),
                        "data":$form.serialize(),
                        "dataType":"json",
                        "cache": true, 
                        "success":function(data){
                            $("#tax").html(data.tax);	
                        },                           
                    }).done(function(data) {
                        if(!data.success) {
                            $form.yiiActiveForm('updateMessages', data, true);
                        }
                    });

                    return false; // prevent default submit
                });
</script>

Also, any plans to add recaptcha V3? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions