Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two recaptcha v2 componet same page #101

Open
prabodhana opened this issue Nov 25, 2021 · 2 comments
Open

Two recaptcha v2 componet same page #101

prabodhana opened this issue Nov 25, 2021 · 2 comments

Comments

@prabodhana
Copy link

My web application login and signup forms are in same page I need to add two recaptcha component for this two forms. It showing but reset only work with first component other component not responding for reset. I.m also try the render method but its say "reCAPTCHA has already been rendered in this element".

@SuddenDev
Copy link

SuddenDev commented Mar 22, 2022

I used v-if as described here: #100 (comment)

@zoxon
Copy link

zoxon commented Feb 15, 2023

This example does't work for me because I get error reCAPTCHA has already been rendered in this element

My workaround

export default {
  data() {
    return {
      widgetId: 0,
    };
  },

  mounted() {
    if (window.__vueWidgetId === undefined) {
      window.__vueWidgetId = 0;
    } else {
      window.__vueWidgetId += 1;
    }
    
    // Get correct recaptcha widget id
    this.widgetId = window.__vueWidgetId;
  },

  methods: {
    async onSubmit() {
      if (!this.isValid) {
        retrun;
      }

      const captchaResponse = await this.$recaptcha.getResponse(this.widgetId)
      api.submitForm({...model, captchaResponse})
    }
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants