question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error onChange on resetCaptcha

See original GitHub issue

ngx-captcha version: 7.0.0

Everytime i use resetCaptcha method, is throwing me in console this error

TypeError: _this.onChange is not a function
    at ngx-captcha.js:168
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.f8cdd893844be2043f68.js:6876)
    at Object.onInvoke (core.js:17299)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.f8cdd893844be2043f68.js:6875)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (polyfills.f8cdd893844be2043f68.js:6635)
    at NgZone.push../node_modules/@angular/core/fesm5/core.js.NgZone.run (core.js:17213)

This is the original ngx-captcha.js:168

 BaseReCaptchaComponent.prototype.resetCaptcha = /**
     * Resets captcha
     * @return {?}
     */
    function () {
        var _this = this;
        this.zone.run((/**
         * @return {?}
         */
        function () {
            // reset captcha using Google js api
            _this.reCaptchaApi.reset();
            // required due to forms
            _this.onChange(undefined);
            _this.onTouched(undefined);
            // trigger reset event
            _this.reset.next();
        }));
    };

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Enngagecommented, Aug 12, 2019

That seems to be working fine on the live demo. You can see the implementation at https://github.com/Enngage/ngx-captcha/blob/master/demo/src/re-captcha-2-demo.component.ts

1reaction
Enngagecommented, Aug 12, 2019

Are you providing proper formControl to captcha element? If not, are you using standalone mode such as:

<ngx-invisible-recaptcha #captchaElem
  [siteKey]="siteKey"
  (reset)="handleReset()"
  (ready)="handleReady()"
  (load)="handleLoad()"
  (success)="handleSuccess($event)"
  (expire)="handleExpire()"
  (error)="handleError()"
  [useGlobalDomain]="false"
  [theme]="theme"
  [type]="type"
  [badge]="badge"
  [ngModel]="recaptcha"
  [ngModelOptions]="{ standalone: true }">
</ngx-invisible-recaptcha>

This seems to be working on the demo app. It is defined at https://github.com/Enngage/ngx-captcha/blob/master/demo/src/invisible-recaptcha-demo.component.ts#L29

Read more comments on GitHub >

github_iconTop Results From Across the Web

onChange event not working after window.reacptcha.reset() in ...
Now the problem is that when user clicks on the recaptcha for first time its working fine and instantly the green tick is...
Read more >
onChange breaks after reset · Issue #14 - GitHub
I'm trying to get my Recaptcha component to reset, based on a redux store dispatch, but none of the reset examples here apply...
Read more >
Captcha on reset password form causes error with invalid key
Adding reCaptcha checkbox to reset password form causes problem: “This key is invalid or has already been used. Please reset your password again...
Read more >
How to implement reCAPTCHA in a React application
In this article, we'll demonstrate how to implement reCAPTCHA v2 in a React application and how to verify user tokens in a Node.js...
Read more >
react-google-recaptcha - npm.io
import ReCAPTCHA from "react-google-recaptcha"; function onChange(value) ... getWidgetId() returns the recaptcha widget Id; reset() forces reset.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found