Skip to main content

JavaScript APIs

MTCaptcha JavaScript APIs

A window.mtcaptcha object will be created once the MTCaptcha JavaScript library has loaded. This mtcaptcha object supports the following APIs.

APIDescription
enableTestMode()To enable Automated Test mode with the TestKey. For more details, see Developer Guide - Automated Testing.
getConfiguration()Returns a 'copy' of the configuration object for the captcha. This is primarily used for debugging config settings. Any changes to the returned config object are ignored.
getStatus()Returns the current state of the captcha. For more details of the state object, see Developer Guide - JS Callbacks - State Argument.
getVerifiedToken()Returns the current verifiedToken string, null if not verified.
renderUI()Explicit call to render the captcha, when initialized with config render='explicit'. See Developer Guide - Explicit Render for an asynchronous-safe method to explicitly render the widget.
resetUI()Resets the widget and all its state.
remove()Completely removes the captcha widget from the DOM. The captcha can be re-instantiated by calling renderUI(). This method is useful for single-page web applications.
showMandatory()Shows the message and styling to indicate the captcha is mandatory. This is intended for use with custom form validation. See Developer Guide - Auto Form Validate to have the captcha automatically check and enforce completion on form submit.