Reset recaptcha contact form 7

I have multiple forms(contact form 7) in a page and need to reset the recaptcha after the form is submitted via ajax. I checked recaptcha API and it has grecaptcha.reset(); but it resets only first recaptcha in a page.

Following is the method to target a specific recaptcha according to recaptcha API:

grecaptcha.reset(
    opt_widget_id
)

The problem here is that I cannot get hold on the instance(opt_widget_id) of recaptcha because it is created by contact form 7.

How do I get opt_widget_id in a page having multiple forms, so that I can reset specific recaptcha.

Solutions Collecting From Web of "Reset recaptcha contact form 7"

Since the recaptcha is created by contact form 7 without assigning the rendered recaptcha to a variable it was not possible to use grecaptcha.reset(opt_widget_id).
Here is what is did:

$(".wpcf7-submit").click(function(event) {
var currentForm=$(this).closest("form");
$( document ).ajaxComplete(function(event,request, settings) {
    var responseObj=JSON.parse(request.responseText);
    if(responseObj.mailSent==true){
        //reset recaptcha
        var recaptchaIFrame=currentForm.find("iframe").eq(0);
        var recaptchaIFrameSrc=recaptchaIFrame.attr("src");
        recaptchaIFrame.attr("src",recaptchaIFrameSrc);
    }
   });
});

I have cleared the iframe source and reassigned the same src so that it reloads the recaptcha once it has been submitted.

I hope this helps someone !

I have done this by adding below code in ‘Additional settings’ of contact form.

on_sent_ok: "grecaptcha.reset()"

Hope this helps to others