Search.../

onError( )

Adds an event handler that runs when a connection error occurs while completing the CAPTCHA challenge.

Description

The onError() function allows you to perform actions when the reCAPTCHA element on the client side loses connection with the CAPTCHA provider.

If an error occurs, the reCAPTCHA element automatically resets. You can ask the site visitor to retry the CAPTCHA challenge later.

Syntax

function onError(handler: ErrorHandler): void
handler: function ErrorHandler(): void

onError Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when an error occurs.

Returns

This function does not return anything.

Return Type:

void

ErrorHandler Parameters

This function does not take any parameters.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Register a callback to run when an error occurs

In this example, the onError() event handler runs, indicating a connection problem. We flash a temporary message instructing site visitors to try complete the challenge later.

Copy Code
1$w("#myCaptcha").onError(() => {
2 $w("#messageText").text = "The reCAPTCHA element lost connection with the CAPTCHA provider. Try again later.";
3 $w("#messageText").show()
4 .then(() => {
5 $w("#messageText").hide("fade", {"delay": 10000});
6 } );
7} );
8