How to enable your submit button based on reCAPTCHA results

Bjorn Krolsavatar

Bjorn Krols

Published on
31 May 2021

This brief post explains how to keep your submit button disabled until the users passes the reCAPTCHA test.

You can add a callback, executed when the user submits a successful response, to you reCAPTCHA integration via the data-callback attribute.

To enable the submit button when the user passes the test, here's what your HTML should look like:

    <script src="" async defer></script>
    <form action="" method="POST">
      <br />
      <button id="submit-button" type="submit" disabled>Submit</button>
    <script type="text/javascript">
      function callback() {
        const submitButton = document.getElementById("submit-button");

Subscribe to our newsletter

The latest news, articles, and resources, sent to your inbox weekly.

More like this