How to Reload ReCaptcha using JavaScript?

AhmetB - Google picture AhmetB - Google · Jul 30, 2010 · Viewed 167.5k times · Source

I have a signup form with AJAX so that I want to refresh Recaptcha image anytime an error is occured (i.e. username already in use).

I am looking for a code compatible with ReCaptcha to reload it using JavaScript.

Answer

AhmetB - Google picture AhmetB - Google · Aug 11, 2010

For reCaptcha v2, use:

grecaptcha.reset();

If you're using reCaptcha v1 (probably not):

Recaptcha.reload();

This will do if there is an already loaded Recaptcha on the window.

(Updated based on @SebiH's comment below.)