reCAPTCHA and this strange Uncaught TypeError

During some refactoring and code improvements in OpenSpaceLint (a validator for a specific json schema implementation) I replaced a Javascript module by some equivalent PHP code and for whatever reason I suddenly wasn’t able to use google’s reCAPTCHA anymore. If you don’t know reCAPTCHA that’s a tool to block automated spam where some text from images have to be manually copied to a text field.


When reaching the reCAPTCHA code only exceptions were thrown and no antibot validation took place.

Uncaught ReferenceError: RecaptchaState is not defined
Uncaught TypeError: Cannot call method 'addEventListener' of null
Uncaught TypeError: Cannot call method 'focus' of null

After a lot of investigation and going through several git commits and finally comparing the beta version with the production code I found out that in a config file wrong credentials were used for the domain under which the beta version was running. When you create your public and private key in your reCAPTCHA account you have to specify a domain for which the keys are valid.

In my case I must have edited the configuration file or copied it from the production code such that the used keys just became invalid with the domain of the test system.

Before you’re driving crazy, check your keys.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>