Wie man die rückruffunktion von reCaptcha findet

Updated on

To solve the problem of finding the reCAPTCHA callback function, here are the detailed steps:

👉 Skip the hassle and get the ready to use 100% working script (Link in the comments section of the YouTube Video) (Latest test 31/05/2025)

  1. Identify the reCAPTCHA version: Determine if you’re using reCAPTCHA v2 checkbox or invisible or v3. The approach differs slightly.
  2. For reCAPTCHA v2 Checkbox/Invisible:
    • Data-callback attribute: Look for data-callback in your div element where the reCAPTCHA widget is rendered. For example: <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY" data-callback="yourCallbackFunctionName"></div>. The value yourCallbackFunctionName is the name of your JavaScript function.
    • grecaptcha.render method: If you’re rendering reCAPTCHA programmatically, check the options object passed to grecaptcha.render. The callback function will be specified under the callback property. Example: grecaptcha.render'your-div-id', { 'sitekey' : 'YOUR_SITE_KEY', 'callback' : yourCallbackFunctionName }..
  3. For reCAPTCHA v3:
    • grecaptcha.execute method: reCAPTCHA v3 doesn’t have a direct data-callback attribute on a div because it’s usually executed programmatically. You’ll find the callback function as the second argument or within an options object of grecaptcha.execute. For instance: grecaptcha.execute'YOUR_SITE_KEY', {action: 'submit'}.thenfunctiontoken { // your callback function starts here }.. The then method of the Promise returned by execute is where your callback logic resides, handling the reCAPTCHA token.
    • Integration with Form Submission: Often, reCAPTCHA v3 is integrated directly into a form’s submit event listener or a button’s click event, where grecaptcha.execute is called, and the subsequent then block processes the token before submitting the form.

Understanding reCAPTCHA Callbacks: The Essential Hook

Navigating the intricacies of web security, especially with tools like Google’s reCAPTCHA, can feel like deciphering an ancient scroll. However, the reCAPTCHA callback function is less of a mystical secret and more of a practical hook—your direct line to what happens after a user successfully or unsuccessfully interacts with the reCAPTCHA widget. Think of it as the ‘next step’ instruction for your website, telling it what to do once reCAPTCHA has done its job. Without understanding and properly implementing this callback, your security measures might just be half-baked. It’s the linchpin that connects the reCAPTCHA verification to your server-side validation, ensuring that only legitimate user actions proceed. On average, websites using reCAPTCHA block over 2.5 billion malicious requests per day, highlighting the critical role of robust integration.

What is a reCAPTCHA Callback Function?

At its core, a reCAPTCHA callback function is a JavaScript function that gets executed by the reCAPTCHA API once a user has successfully completed the reCAPTCHA challenge.

For reCAPTCHA v2 the “I’m not a robot” checkbox or the invisible variant, this function is triggered when the user passes the test, and it receives a response token as an argument. This token is crucial.

It’s the proof of successful verification that you then send to your server for final validation.

Without it, your reCAPTCHA implementation is essentially just a visual hurdle, offering no real protection. Solve re v2 guide

This token is valid for approximately two minutes, meaning your server-side validation must occur within this window.

Why is the Callback Function So Important?

The callback function is the bridge between the client-side reCAPTCHA interaction and your server-side security logic. It’s the mechanism that:

  • Obtains the reCAPTCHA response token: This token is the cryptographic proof that Google has verified the user.
  • Allows for immediate action: Upon successful verification, you can enable a disabled form submission button, display a success message, or initiate an AJAX request to your server.
  • Enables server-side validation: The token obtained in the callback is sent to your backend, where you perform a final verification with Google’s API to ensure the token is legitimate and hasn’t been tampered with. This dual-layer validation is paramount for robust security. Reports indicate that over 90% of all internet traffic is bot-generated, making robust validation essential.
  • Handles expired tokens: A separate callback data-expired-callback can be used to reset the form or re-enable the reCAPTCHA if the token expires before submission.

Implementing reCAPTCHA v2 Callbacks: The Checkbox and Invisible Shield

ReCAPTCHA v2 offers a clear, user-interactive approach with the checkbox or a more seamless, invisible version.

Both rely heavily on properly configured callback functions to pass the verification token.

Getting this right means your form submission can proceed confidently, knowing a bot hasn’t just slipped through. Ai web scraping and solving captcha

Approximately 70% of websites that use reCAPTCHA still rely on v2 for its clear user interaction and explicit verification step.

How to Find and Define the data-callback Attribute

For reCAPTCHA v2, the most common way to define the callback is through the data-callback attribute directly within the div element where the reCAPTCHA widget is rendered.

Finding it:

  1. Inspect your HTML: Open your website in a browser, right-click on the reCAPTCHA widget, and select “Inspect” or “Inspect Element”.
  2. Locate the div: Look for a div element with the class g-recaptcha.
  3. Check data-callback: Within this div, you’ll likely find an attribute like data-callback="yourFunctionName". The value of this attribute is the name of your JavaScript function that will be executed.

Defining it:

If you’re setting this up, your HTML should look like this: Recaptchav2 v3 2025



<form id="myForm" action="/submit-form" method="POST">
    <!-- Other form fields -->


   <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY" data-callback="onRecaptchaSuccess"></div>


   <input type="submit" value="Submit" id="submitBtn" disabled>
</form>

<script type="text/javascript">
    function onRecaptchaSuccesstoken {
        console.log"reCAPTCHA token:", token.


       // Enable the submit button or submit the form via AJAX


       document.getElementById'submitBtn'.disabled = false.
        // Optionally, send the token via AJAX:
        // sendTokenToServertoken.
    }

    // You might also need an expired callback
    function onRecaptchaExpired {
        console.log"reCAPTCHA token expired.".


       document.getElementById'submitBtn'.disabled = true.


       // Optionally, reset the reCAPTCHA widget if needed for explicit rendering
        // grecaptcha.reset.
</script>

In this example, onRecaptchaSuccess is your callback function. The data-sitekey is unique to your domain.

You also have data-expired-callback to handle token expiration, a crucial but often overlooked detail.

Programmatic Rendering with grecaptcha.render

Alternatively, you might render reCAPTCHA v2 programmatically using grecaptcha.render. This is common when you want more control over the widget’s appearance or if you’re loading it dynamically.

Look for JavaScript code that calls grecaptcha.render. It will typically take two arguments:

  1. The ID of the HTML element where the reCAPTCHA should be rendered.
  2. An object containing configuration options.

The callback property within this options object is where your callback function is defined. Hrequests

 var onloadCallback = function {
     grecaptcha.render'recaptcha-container', {
         'sitekey' : 'YOUR_SITE_KEY',
         'callback' : onRecaptchaSuccess,


        'expired-callback': onRecaptchaExpired, // Important for user experience
         'theme' : 'light'
     }.
 }.



    console.log"reCAPTCHA token from programmatic render:", token.
     // ... same logic as above



    console.log"reCAPTCHA token expired from programmatic render.".

Here, onloadCallback is a function that runs after the reCAPTCHA API script loads. Inside it, grecaptcha.render explicitly tells reCAPTCHA where to place the widget and what callback and expired-callback functions to use. This method gives you granular control and is often preferred in complex single-page applications.

Implementing reCAPTCHA v3 Callbacks: The Invisible Guardian

ReCAPTCHA v3 operates almost entirely in the background, providing a score based on user interaction rather than a direct “I’m not a robot” challenge.

This makes it ideal for protecting critical actions without disrupting the user experience.

However, its callback mechanism is different—it’s typically integrated directly into your event listeners. Recaptcha image recognition

Over 2.5 million active websites use reCAPTCHA v3, valuing its seamless integration.

Understanding grecaptcha.execute.then for v3

Unlike v2’s explicit data-callback attribute on an HTML element, reCAPTCHA v3’s core functionality revolves around programmatically executing the reCAPTCHA check and then handling the returned Promise. This is where your “callback” logic resides.

You’ll typically find grecaptcha.execute calls within JavaScript functions that handle form submissions or specific user actions.



document.getElementById'submitButton'.addEventListener'click', functionevent {


   event.preventDefault. // Prevent default form submission
    grecaptcha.readyfunction {


       grecaptcha.execute'YOUR_SITE_KEY', {action: 'submit_form'}.thenfunctiontoken {


           // This entire function block is your 'callback' for v3


           console.log"reCAPTCHA v3 token:", token.


           // Now send this token to your server for verification
            // submitFormWithTokentoken.
    }.
}.



In this example, the `functiontoken { ... }` block passed to the `.then` method is where you handle the reCAPTCHA v3 token. This is your callback. It receives the token directly.



When you're setting this up, you'll generally wrap your form submission logic within the `then` block of `grecaptcha.execute`.



<form id="contactForm" action="/contact" method="POST">
    <!-- Form fields -->


   <button type="submit" id="contactSubmitBtn">Send Message</button>



<script src="https://www.google.com/recaptcha/api.js?render=YOUR_SITE_KEY"></script>


   document.getElementById'contactSubmitBtn'.addEventListener'click', functionevent {


       event.preventDefault. // Stop default form submission

        // Ensure reCAPTCHA API is ready
        grecaptcha.readyfunction {


           // Execute reCAPTCHA v3 for the 'contact_form' action


           grecaptcha.execute'YOUR_SITE_KEY', {action: 'contact_form'}.thenfunctiontoken {


               // This is your callback for reCAPTCHA v3


               // The 'token' argument holds the reCAPTCHA response


               console.log'reCAPTCHA v3 token:', token.



               // Now, create a hidden input field for the token and append it to the form


               const form = document.getElementById'contactForm'.


               let recaptchaTokenInput = form.querySelector'input'.
                if !recaptchaTokenInput {


                   recaptchaTokenInput = document.createElement'input'.


                   recaptchaTokenInput.type = 'hidden'.


                   recaptchaTokenInput.name = 'recaptchaToken'.


                   form.appendChildrecaptchaTokenInput.
                }
                recaptchaTokenInput.value = token.



               // Finally, submit the form programmatically
                form.submit.
            }.



Here, the submission of `contactForm` is gated by the reCAPTCHA execution.

Only after `grecaptcha.execute` returns a token which indicates successful verification by Google is the form actually submitted, with the token included for server-side validation.

This ensures a seamless user experience while still providing robust bot protection.

# Integrating reCAPTCHA v3 with Form Submission Events



A common and highly recommended approach for reCAPTCHA v3 is to integrate its execution directly into your form's `submit` event listener.

This ensures that every form submission is first checked by reCAPTCHA.

Steps:
1.  Prevent default submission: On your form's submit event, `event.preventDefault` to stop the form from submitting immediately.
2.  Execute reCAPTCHA: Call `grecaptcha.execute`.
3.  Handle the token: In the `.then` block of the Promise, retrieve the token.
4.  Append token and submit: Add the token as a hidden input to your form and then programmatically call `form.submit`.



This method is robust because it ensures that the reCAPTCHA check is always performed before the form data leaves the client.

According to Google's reCAPTCHA team, v3 offers a 99.9% effective rate in differentiating between human and bot traffic when properly implemented with server-side validation.

 Server-Side Validation: The Ultimate Callback Destination



Finding the reCAPTCHA callback function on the client-side is only half the battle.

The true validation of a reCAPTCHA token must always happen on your server.

Without this crucial server-side check, a malicious actor could bypass client-side JavaScript, submit a form without a valid token, or even reuse an old token.

This server-side step is your final gatekeeper, ensuring the reCAPTCHA response is legitimate and hasn't been forged or expired.

Research by Sucuri Security indicates that approximately 60% of all website attacks originate from bots, making server-side validation indispensable.

# Why Server-Side Validation is Non-Negotiable

Client-side reCAPTCHA is easily bypassed. A sophisticated bot can simply ignore your JavaScript and send direct requests to your server. The reCAPTCHA token itself is a crucial piece of evidence that Google verifies a user, but *your server* must ask Google to confirm this evidence.

Here's why it's non-negotiable:
*   Preventing token reuse: Google's verification API ensures each token is used only once and expires quickly typically within 2 minutes. Your server-side check enforces this.
*   Authenticity check: Your server communicates directly with Google's reCAPTCHA API, confirming the token's authenticity, the `sitekey` used, and that the request originated from your domain.
*   Score analysis v3: For reCAPTCHA v3, the server-side check receives a score 0.0 to 1.0 and other metadata. Your server can then decide if the interaction is legitimate enough to proceed e.g., score > 0.5 or if further action is needed e.g., block, flag for review, or present a v2 challenge.
*   Security layer: It's the ultimate defense against automated attacks, spam, and credential stuffing. A recent report found that 85% of credential stuffing attacks were blocked by advanced reCAPTCHA implementations.

# Steps to Implement Server-Side Validation



Regardless of whether you're using reCAPTCHA v2 or v3, the server-side validation process is fundamentally the same:

1.  Retrieve the token: On your server, when a form is submitted, extract the reCAPTCHA token that was sent from the client-side. This is typically found in your POST request data e.g., `$_POST` or `$_POST` if you named it differently for v3.
2.  Prepare the verification request:
   *   URL: `https://www.google.com/recaptcha/api/siteverify`
   *   Method: POST
   *   Parameters:
       *   `secret`: Your reCAPTCHA secret key NOT your site key. This key is unique to your application and should *never* be exposed client-side.
       *   `response`: The reCAPTCHA token received from the client.
       *   `remoteip` optional but recommended: The IP address of the user making the request.
3.  Send the request: Use a server-side HTTP client e.g., `cURL` in PHP, `requests` in Python, `fetch` in Node.js to send the POST request to Google's verification API.
4.  Parse the response: Google's API will return a JSON response. The critical fields are:
   *   `"success": true | false` boolean indicating if the token is valid
   *   `"score": float` v3 only, likelihood of being human, 0.0-1.0
   *   `"action": string` v3 only, the action name you defined when executing reCAPTCHA
   *   `"challenge_ts": string` timestamp of the challenge load
   *   `"hostname": string` hostname of the site where the challenge was solved
   *   `"error-codes": array` if `success` is false
5.  Act based on the response:
   *   If `"success"` is `true` and for v3, `score` is acceptable and `action` matches, proceed with your form processing or desired action.
   *   If `"success"` is `false`, or if the v3 `score` is too low, treat the request as potentially malicious. You might reject the submission, log the attempt, or present a tougher challenge.

Example PHP:

```php
<?php
// Function to verify reCAPTCHA on the server-side


function verifyRecaptcha$token, $secretKey, $userIp = null {


   $url = 'https://www.google.com/recaptcha/api/siteverify'.
    $data = 
        'secret'   => $secretKey,
        'response' => $token,
    .
    if $userIp {
        $data = $userIp.

    $options = 
        'http' => 


           'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'POST',
            'content' => http_build_query$data,
        ,
    $context  = stream_context_create$options.


   $result = file_get_contents$url, false, $context.
    return json_decode$result, true.
}

// In your form submission handler:
if $_SERVER === 'POST' {


   $recaptchaToken = $_POST ?? ''. // For v2


   // Or for v3, if you named your hidden input 'recaptchaToken':


   // $recaptchaToken = $_POST ?? ''.



   $secretKey = 'YOUR_SECRET_KEY'. // Replace with your actual secret key
    $userIp = $_SERVER ?? null. // Get user's IP



   $response = verifyRecaptcha$recaptchaToken, $secretKey, $userIp.

    if $response {
        // reCAPTCHA verification successful


       if isset$response && $response < 0.5 {


           // reCAPTCHA v3: score too low, potentially a bot


           error_log"Low reCAPTCHA score for user: " . $userIp.


           // Optionally, log this attempt and return an error to the user
            echo "Verification failed. Please try again or contact support.".
        } else {


           // It's a human, proceed with form processing


           // e.g., save to database, send email, etc.
            echo "Form submitted successfully!".
        }
    } else {


       // reCAPTCHA verification failed e.g., invalid token, token expired


       error_log"reCAPTCHA verification failed for IP: " . $userIp . " Errors: " . implode", ", $response ?? .
        echo "reCAPTCHA verification failed. Please try again.".
?>



This ensures that even if a bot tries to bypass client-side checks, your server acts as the ultimate authority, rejecting any unverified or suspicious requests.

 Troubleshooting Common Callback Issues: When Things Go Sideways



Even with the best intentions and meticulous planning, integrating reCAPTCHA callbacks can sometimes hit snags.

When your forms aren't submitting, or reCAPTCHA seems stuck, a structured troubleshooting approach is key. Don't throw your hands up in despair.

these are often simple configuration errors or timing issues.

A survey by Akamai found that misconfigurations were responsible for 68% of security incidents, underscoring the importance of proper setup.

# Callback Function Not Firing

This is perhaps the most common issue.

Your reCAPTCHA widget appears, but nothing happens after a user completes the challenge.

Possible Causes and Solutions:

1.  Incorrect `data-callback` or `callback` name:
   *   Check: Double-check that the string assigned to `data-callback` for v2 HTML rendering or the `callback` property for v2 programmatic rendering exactly matches the name of your JavaScript function. Case sensitivity matters!
   *   Solution: Correct the spelling. E.g., if your function is `onRecaptchaSuccess`, ensure `data-callback="onRecaptchaSuccess"`.
2.  Function not in global scope:
   *   Check: For `data-callback`, the function needs to be globally accessible i.e., defined directly in a `<script>` tag or on the `window` object. If it's nested inside another function or a module, reCAPTCHA won't find it.
   *   Solution: Move your callback function out of any immediate function wrappers or explicitly attach it to `window`: `window.onRecaptchaSuccess = functiontoken { ... }.`.
3.  JavaScript errors preventing execution:
   *   Check: Open your browser's developer console F12, then go to the "Console" tab. Look for any JavaScript errors. An error in an unrelated script on your page could halt execution before your callback is registered or fired.
   *   Solution: Fix any preceding JavaScript errors. Use `console.log` statements within your callback to confirm it's being reached.
4.  reCAPTCHA API script not loaded:
   *   Check: Ensure the reCAPTCHA API script `https://www.google.com/recaptcha/api.js` is correctly loaded. Is there a network error in the "Network" tab of your developer console? Is it loaded before your reCAPTCHA div or programmatic render call?
   *   Solution: Ensure the script tag is present and reachable. For v2, it's often placed before the closing `</body>` tag or in the `<head>`. For explicit rendering, ensure the `onload` parameter matches your callback function.
5.  Using `async` / `defer` improperly:
   *   Check: If you're using `async` or `defer` attributes on the reCAPTCHA script tag, ensure your rendering logic especially programmatic `grecaptcha.render` waits for the `onloadCallback` or `grecaptcha.ready` for v3 before attempting to interact with `grecaptcha`.
   *   Solution: For explicit rendering, use `?onload=yourCallback&render=explicit`. For v3, always wrap `grecaptcha.execute` calls within `grecaptcha.readyfunction { ... }.`.

# Token Not Being Sent to Server



You know the callback is firing, but your server isn't receiving the token.


1.  Missing hidden input field v2:
   *   Check: For traditional form submissions, ensure you've created a hidden input field named `g-recaptcha-response` and populated its `value` attribute with the token received in your callback.
   *   Solution:
        ```javascript
        function onRecaptchaSuccesstoken {


           document.getElementById'g-recaptcha-response-input'.value = token.
            // Also enable submit button if needed


           document.getElementById'submitBtn'.disabled = false.
        // In your HTML:


       <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response-input">
        ```
2.  AJAX request not including token:
   *   Check: If you're submitting the form via AJAX, ensure the reCAPTCHA token is explicitly included in the data payload you send to the server.
            fetch'/submit-form', {
                method: 'POST',


               headers: {'Content-Type': 'application/json'},
                body: JSON.stringify{
                    // Other form data


                   recaptchaToken: token // Key is important, match on server
                }
            }.thenresponse => response.json
              .thendata => console.logdata.
3.  Form submission happening too early v3:
   *   Check: For v3, if you're submitting the form within the `grecaptcha.execute.then` block, ensure you're explicitly creating the hidden input for the token and then programmatically submitting the form *after* the token is assigned.




           const form = document.getElementById'myForm'.


           let tokenInput = form.querySelector'input'.
            if !tokenInput {


               tokenInput = document.createElement'input'.
                tokenInput.type = 'hidden'.


               tokenInput.name = 'recaptchaToken'.
                form.appendChildtokenInput.
            }
            tokenInput.value = token.


           form.submit. // Submit the form ONLY after token is set

# reCAPTCHA Expires Before Submission



This happens with reCAPTCHA v2 the checkbox when a user takes too long to submit the form after checking the box.


1.  Token expiry usually ~2 minutes:
   *   Check: The token is only valid for a short period. If the user fills out a long form, the token might expire.
   *   Solution: Implement the `data-expired-callback` for HTML rendering or `expired-callback` for programmatic rendering to handle this.
        ```html


       <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY" data-callback="onRecaptchaSuccess" data-expired-callback="onRecaptchaExpired"></div>
        <script>
           function onRecaptchaSuccesstoken { /* ... */ }
            function onRecaptchaExpired {


               console.log"reCAPTCHA token expired. Please re-verify.".
                // Disable submit button again


               document.getElementById'submitBtn'.disabled = true.


               // Optionally, reset the reCAPTCHA widget especially for invisible reCAPTCHA
                grecaptcha.reset.
        </script>


       This callback will fire when the token expires, allowing you to re-enable the reCAPTCHA challenge or instruct the user to re-verify.



By systematically going through these common issues, you can debug most reCAPTCHA callback problems efficiently, ensuring your website remains secure and user-friendly.

 Best Practices for Robust reCAPTCHA Implementation: Beyond the Basics



Implementing reCAPTCHA isn't just about dropping a few lines of code.

it's about thoughtful integration that enhances security without sacrificing user experience.

Think of it as building a fortified gate: you need strong materials, a reliable lock, and a smart gatekeeper.

Neglecting best practices can leave your site vulnerable, turning your security measure into a mere illusion.

Data from Imperva indicates that bot attacks increased by 40% in 2023, underscoring the ongoing need for robust defense.

# Always Perform Server-Side Validation

This cannot be stressed enough.

As discussed, client-side reCAPTCHA can be bypassed.

The server-side validation is your ultimate and most critical line of defense.

*   Rationale: Client-side JavaScript can be disabled or manipulated by bots. The `g-recaptcha-response` token or v3 token is merely a proof of concept *from the client's perspective*. Your server must independently confirm with Google that the token is valid, unique, and was generated for your site.
*   Actionable Tip: Every form submission or protected action that uses reCAPTCHA *must* include a backend call to `https://www.google.com/recaptcha/api/siteverify`. Ensure your server-side code handles potential errors from Google's API, such as network issues or invalid secret keys.

# Handle Token Expiration Gracefully reCAPTCHA v2



reCAPTCHA v2 tokens expire after approximately two minutes.

If a user starts filling out a long form and the token expires before submission, you need a mechanism to handle this.

*   Rationale: A poor user experience arises if the form silently fails because the reCAPTCHA token expired. Users will get frustrated and potentially abandon your site.
*   Actionable Tip: Utilize the `data-expired-callback` attribute for HTML rendering or `expired-callback` option for programmatic rendering.
    ```html


   <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY"
         data-callback="onRecaptchaSuccess"


        data-expired-callback="onRecaptchaExpired"></div>
    <script>
        function onRecaptchaExpired {


           // Re-enable reCAPTCHA widget if it's invisible or reset it
            grecaptcha.reset.
            // Disable the submit button again


           document.getElementById'submitBtn'.disabled = true.


           // Optionally, show a message to the user: "Please re-verify reCAPTCHA."
    </script>
    ```


   This ensures the user is prompted to re-verify, maintaining security.

# Use Specific Actions for reCAPTCHA v3



For reCAPTCHA v3, specifying an `action` parameter when executing reCAPTCHA is vital for effective analysis.

*   Rationale: The `action` parameter helps Google's reCAPTCHA algorithm understand the context of the user's interaction on your site. This allows it to provide more accurate risk scores, especially when viewing metrics in the reCAPTCHA Admin Console. Unique actions for unique user flows e.g., `login`, `signup`, `checkout`, `contact_form` give you granular data.
*   Actionable Tip: When calling `grecaptcha.execute`, always provide a descriptive action:
    ```javascript
   grecaptcha.execute'YOUR_SITE_KEY', {action: 'contact_form'}.thenfunctiontoken { /* ... */ }.


   Ensure this action name is also checked on the server side during verification to prevent token reuse across different actions.

# Implement a Fallback or Alternative for Low reCAPTCHA v3 Scores



reCAPTCHA v3 provides a score, not a direct pass/fail. You need to decide how to handle lower scores.

*   Rationale: A score of 0.9 is highly likely to be human, while 0.1 is likely a bot. What about 0.4 or 0.6? You need a strategy for these "grey area" scores. Automatically blocking genuine users due to a slightly low score is a poor user experience.
*   Actionable Tip:
   *   Thresholds: Set a score threshold. For instance, if `score >= 0.7`, proceed. If `score < 0.3`, block.
   *   Fallback: For scores in between e.g., 0.3 to 0.6, consider presenting a reCAPTCHA v2 challenge checkbox or another form of secondary verification e.g., email confirmation, simple math question.
   *   Passive Logging: For very low scores, you might simply log the attempt without blocking, to monitor suspicious activity over time. Organizations reported a 75% reduction in account takeover attacks after implementing dynamic reCAPTCHA responses based on risk scores.

# Protect Your Secret Key



Your reCAPTCHA secret key is as sensitive as your database credentials.

*   Rationale: Exposing your secret key client-side or in version control makes it trivial for attackers to forge valid reCAPTCHA responses, completely undermining your security.
*   Actionable Tip: Store your secret key securely on your server, preferably in environment variables or a secure configuration file, not directly in your code. Access it only from your server-side verification logic.

# Consider User Experience and Accessibility



While security is paramount, it shouldn't come at the cost of alienating legitimate users.

*   Rationale: An overly intrusive reCAPTCHA can frustrate users, leading to form abandonment. This is especially true for users with disabilities or those using assistive technologies.
   *   Invisible reCAPTCHA v2 / v3: Prefer these for minimal friction.
   *   Accessibility: Ensure your reCAPTCHA implementation adheres to web accessibility guidelines WCAG. Google's reCAPTCHA widget generally does this, but ensure your surrounding page content doesn't break it.
   *   Error Messages: Provide clear, helpful error messages if reCAPTCHA verification fails, guiding the user on what to do next.



By adhering to these best practices, you can build a reCAPTCHA implementation that is not only effective at blocking bots but also seamless and user-friendly for your legitimate audience.

 ReCAPTCHA Alternatives and Ethical Considerations: Beyond Google



While Google reCAPTCHA is a dominant force in bot protection, it's not the only option.

As a Muslim professional, one might always seek solutions that offer flexibility, data privacy considerations, and align with broader ethical principles, particularly concerning data sovereignty and control.

While reCAPTCHA is effective, relying solely on a single large entity for security might not always align with distributed, privacy-conscious approaches.

Additionally, a diverse range of alternatives offers different features, pricing models, and levels of control over user data.

Some estimates suggest that the global market for bot management solutions is growing at a CAGR of 25%, indicating a strong demand for diverse security options.

# Why Consider Alternatives?

1.  Data Privacy Concerns: Google, like any large tech company, collects data. While reCAPTCHA states it's used for improving their service, some organizations or individuals might prefer solutions with different data handling policies or those that process data entirely on your own servers.
2.  Vendor Lock-in: Relying heavily on one platform can create dependency. Exploring alternatives diversifies your security stack.
3.  Customization: Some alternatives offer greater customization options for appearance, challenge types, or integration flexibility.
4.  Performance: While reCAPTCHA is generally fast, some alternatives might offer better performance in specific geographical regions or for particular use cases.
5.  Cost: For very high-volume sites, alternative services might offer more competitive pricing or a transparent pay-as-you-go model. While reCAPTCHA is free, for enterprise-level usage, other services might offer dedicated support and features for a fee.

# Notable reCAPTCHA Alternatives



Here are a few prominent alternatives that offer different approaches to bot detection:

1.  hCaptcha:
   *   Concept: A privacy-focused, ethical, and enterprise-grade alternative to reCAPTCHA. It uses human challenges like image recognition but also leverages advanced machine learning to detect bots.
   *   Key Differentiator: Emphasizes privacy. Users solving hCaptcha challenges are contributing to machine learning datasets for companies, and hCaptcha pays website owners for these challenges though often a small amount. It is designed to be GDPR and CCPA compliant.
   *   Integration: Very similar API to reCAPTCHA, making migration relatively straightforward. Uses `data-callback` and server-side verification.
   *   Good for: Websites prioritizing privacy, those looking for an ethical alternative, or large enterprises needing a robust, privacy-first bot defense.
   *   Callback: Similar to reCAPTCHA v2, it uses a `data-callback` attribute or `hcaptcha.render` with a `callback` option. Server-side verification is also mandatory.

2.  Cloudflare Bot Management / Super Bot Fight Mode:
   *   Concept: An advanced bot detection and mitigation service offered by Cloudflare as part of their broader security suite. It analyzes incoming traffic patterns, headers, and behaviors at the network edge to identify and block bots.
   *   Key Differentiator: Operates at the network layer, often before traffic even reaches your web server. It doesn't rely on a client-side widget for every interaction, making it very transparent to legitimate users. It uses machine learning to identify new bot threats.
   *   Integration: Integrates directly with your Cloudflare account. Requires your domain to be proxied through Cloudflare.
   *   Good for: Websites already using Cloudflare, or those needing comprehensive network-level bot protection for large-scale operations. It reduces the need for client-side challenges for most traffic.
   *   Callback: Not a direct client-side callback in the same sense as reCAPTCHA. Instead, it offers server-side rules and actions e.g., challenge, block, log based on its bot score.

3.  Arkose Labs:
   *   Concept: Focuses on disrupting automated attacks by presenting adaptive challenges that frustrate bots but are solvable by humans. Their approach is more about "deterrence" than just detection.
   *   Key Differentiator: Challenges are dynamic and adaptive. If a bot attempts to bypass one, the system presents a harder, more complex one. They often combine behavioral biometrics with visual challenges.
   *   Integration: Requires integration of their SDK and server-side validation.
   *   Good for: High-value targets facing sophisticated, persistent bot attacks e.g., financial services, gaming platforms.

4.  Botify or similar specialized bot detection APIs:
   *   Concept: Dedicated API-based services that analyze various signals to identify and mitigate bot traffic. They often provide more detailed analytics and integration options than basic CAPTCHA services.
   *   Key Differentiator: Focus on advanced threat intelligence and real-time behavioral analysis. Can integrate deeply into your application logic.
   *   Integration: Typically involves API calls from your server or proxy.
   *   Good for: Businesses needing highly customized, scalable bot protection with detailed reporting, often for specific attack vectors like credential stuffing or scraping.

When evaluating alternatives, consider:
*   Ease of integration: How much effort will it take to switch?
*   Privacy policies: How is user data handled?
*   Effectiveness: How well does it detect and mitigate the specific types of bot attacks you face?
*   Cost: What's the pricing model for your traffic volume?
*   Impact on UX: How does it affect the user journey?



Ultimately, the best solution depends on your specific needs, traffic patterns, and security posture.

It's often wise to evaluate a few options and even run trials to see which performs best for your unique environment.

 The Role of JavaScript and Asynchronous Loading: Powering the Callback



JavaScript is the engine behind reCAPTCHA's client-side operation and, consequently, the callback function.

Understanding how reCAPTCHA integrates with the page's JavaScript execution, especially concerning asynchronous loading, is crucial for smooth implementation.

Incorrect loading can lead to your callback function not being found or executed at the right time.

In 2023, JavaScript remained the most commonly used programming language, powering 98% of all websites, underscoring its foundational role in modern web development.

# How JavaScript Enables the Callback



When you include the reCAPTCHA API script on your page:




or for v3:




Google's script does several things:
*   Loads the reCAPTCHA API: It fetches all the necessary JavaScript files to run the reCAPTCHA widget or invisible service.
*   Defines `grecaptcha` object: Once loaded, it makes the `grecaptcha` object globally available, which contains methods like `render`, `execute`, and `reset`.
*   Triggers `onloadCallback` for explicit rendering: If you use `onload=yourCallback` in the script URL, Google's script will automatically call `window.yourCallback` once its API is fully loaded and ready to be used. This is why your rendering logic often sits inside this `onloadCallback`.
*   Monitors widget state for v2: For the `data-callback` attribute on a `div`, the reCAPTCHA API JavaScript constantly monitors the state of that widget. When a user successfully completes the challenge, it finds the function name specified in `data-callback` and executes it, passing the token.
*   Provides `grecaptcha.ready` for v3 and general readiness: For reCAPTCHA v3, and as a more robust general approach for v2, `grecaptcha.readyfunction { ... }.` ensures that your code that interacts with the `grecaptcha` object only runs *after* the reCAPTCHA API has fully loaded and initialized. This prevents "grecaptcha is not defined" errors.

# The Nuances of Asynchronous Loading `async` and `defer`



The `async` and `defer` attributes on script tags are vital for optimizing page load times, but they can affect when your reCAPTCHA-related JavaScript runs.

*   `async` attribute:
   *   Behavior: The script is downloaded asynchronously while the HTML parsing continues. Once downloaded, it executes immediately, pausing HTML parsing.
   *   Impact on reCAPTCHA: If your reCAPTCHA script is `async` and your HTML `div` with `data-callback` or your `grecaptcha.render` call appears *before* the `async` script has finished downloading and executing, your `data-callback` might not be registered correctly, or `grecaptcha` might be `undefined`.
   *   Best Practice: When using `async` for the reCAPTCHA script, always rely on the `onload` parameter for explicit rendering or `grecaptcha.ready` for any `grecaptcha.execute` calls to ensure the API is fully loaded before you try to interact with it.

*   `defer` attribute:
   *   Behavior: The script is downloaded asynchronously, but its execution is *deferred* until the HTML parsing is complete. Scripts with `defer` execute in the order they appear in the HTML.
   *   Impact on reCAPTCHA: `defer` is generally safer for reCAPTCHA if you're mixing it with other scripts, as it ensures your page's DOM is largely ready. However, you still need to ensure `grecaptcha` is available before calling its methods.
   *   Best Practice: Similar to `async`, use `onload` or `grecaptcha.ready` to ensure proper synchronization.

Example using `grecaptcha.ready` most robust for v3 and mixed scenarios:

<!DOCTYPE html>
<html>
<head>
    <title>reCAPTCHA Example</title>
    <!-- Other head elements -->
</head>
<body>
    <form id="myContactForm">


       <input type="text" placeholder="Your Name">
        <button type="submit">Send</button>
    </form>

    <!-- Asynchronously load reCAPTCHA v3 API -->


   <script src="https://www.google.com/recaptcha/api.js?render=YOUR_SITE_KEY" async defer></script>

       // This script block runs *after* the DOM is largely parsed because of defer on recaptcha.js


       // But we still need to wait for grecaptcha to be fully ready


       document.getElementById'myContactForm'.addEventListener'submit', functionevent {


           event.preventDefault. // Stop default form submission

            grecaptcha.readyfunction {


               // This code only runs once the reCAPTCHA API is fully loaded and ready


               grecaptcha.execute'YOUR_SITE_KEY', {action: 'submit_contact'}.thenfunctiontoken {


                   console.log'reCAPTCHA v3 token:', token.



                   // Create a hidden input for the token and append to form


                   const form = document.getElementById'myContactForm'.


                   let tokenInput = form.querySelector'input'.
                    if !tokenInput {


                       tokenInput = document.createElement'input'.


                       tokenInput.type = 'hidden'.


                       tokenInput.name = 'g-recaptcha-response'. // Standard name for server-side


                       form.appendChildtokenInput.
                    }
                    tokenInput.value = token.

                    // Now submit the form
                    form.submit.
                }.
</body>
</html>



By understanding how JavaScript loads and executes, especially with `async` and `defer`, you can prevent common timing issues that lead to reCAPTCHA callback failures, ensuring a reliable and secure user flow.

 Common Pitfalls and Advanced Callback Patterns: Leveling Up Your reCAPTCHA Game



Beyond the basic implementation, there are nuances and advanced patterns that can trip up even experienced developers.

Mastering these will not only resolve nagging issues but also allow for more sophisticated and robust reCAPTCHA integrations.

According to a study by Forrester, complex web applications often see a 15-20% failure rate in reCAPTCHA implementations due to unaddressed edge cases.

# Multiple reCAPTCHA Widgets on One Page



Occasionally, you might need more than one reCAPTCHA widget on a single page e.g., a login form and a registration form, or multiple comment forms. This requires careful handling of callbacks.

*   Pitfall: Using the same `data-callback` function name for multiple reCAPTCHA widgets will lead to only the first one being properly managed or unexpected behavior. Each widget needs a unique callback.
*   Solution Programmatic Rendering with Unique IDs: The most robust way to handle multiple reCAPTCHA instances is to render them programmatically using `grecaptcha.render`.
    <div id="recaptcha1"></div>
    <div id="recaptcha2"></div>

    <script type="text/javascript">
        var onloadCallback = function {
            // Widget 1 for login form
            grecaptcha.render'recaptcha1', {
                'sitekey' : 'YOUR_SITE_KEY',


               'callback' : onLoginRecaptchaSuccess,
                'theme' : 'light'

            // Widget 2 for registration form
            grecaptcha.render'recaptcha2', {


               'callback' : onRegisterRecaptchaSuccess,


               'theme' : 'dark' // Different theme for example
        }.

        function onLoginRecaptchaSuccesstoken {


           console.log"Login reCAPTCHA token:", token.


           // Handle token for login form submission



       function onRegisterRecaptchaSuccesstoken {


           console.log"Register reCAPTCHA token:", token.


           // Handle token for registration form submission


   <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>


   This ensures each reCAPTCHA widget has its own dedicated callback function, allowing you to manage their respective form submissions independently.

# Dynamically Created Forms or Widgets

What if your forms or reCAPTCHA widgets are added to the DOM *after* the initial page load via AJAX or JavaScript?

*   Pitfall: The `g-recaptcha` class attribute and `data-callback` won't automatically be picked up by the reCAPTCHA API if the element is added after the API has already initialized and scanned the DOM.
*   Solution Programmatic Rendering after Dynamic Content Load: You need to explicitly tell `grecaptcha` to render the widget after your dynamic content has been inserted.
   // Assume you have an AJAX call that loads new content with a div#dynamic-recaptcha-container
    function loadDynamicFormAndRecaptcha {
        // ... AJAX call to get form HTML


       document.getElementById'some-container'.innerHTML = '<div id="dynamic-recaptcha-container"></div><form id="dynamicForm">...</form>'.



       // Now that the div is in the DOM, render reCAPTCHA


       grecaptcha.render'dynamic-recaptcha-container', {
            'callback' : onDynamicRecaptchaSuccess

    function onDynamicRecaptchaSuccesstoken {


       console.log"Dynamic reCAPTCHA token:", token.
        // Handle token for dynamic form



   // Call loadDynamicFormAndRecaptcha when your dynamic content is ready
   Always call `grecaptcha.render` *after* the target `div` element is present in the DOM. For reCAPTCHA v3, ensure you wrap any `grecaptcha.execute` calls within `grecaptcha.ready` if you're unsure of the API's load state, especially in Single Page Applications SPAs.

# Handling Callback Context `this` keyword



If your callback function is part of an object or class, the `this` keyword inside the callback might not refer to what you expect when reCAPTCHA invokes it.

*   Pitfall: `this` will usually refer to the `window` object global scope when a globally defined function is called by reCAPTCHA, not your custom object instance.
*   Solution Binding or Arrow Functions:
    class FormHandler {
        constructor {
            this.formId = 'myAuthForm'.
            this.initRecaptcha.

        initRecaptcha {
            grecaptcha.render'recaptcha-div', {
                'sitekey': 'YOUR_SITE_KEY',


               // Use .bindthis to preserve the context of 'this'


               'callback': this.handleRecaptchaSuccess.bindthis

        handleRecaptchaSuccesstoken {


           console.log`Token for ${this.formId}:`, token. // 'this' refers to FormHandler instance
            // ... submit logic



   // In your onloadCallback for grecaptcha.api.js:
        new FormHandler.


   Using `.bindthis` ensures that `this` inside `handleRecaptchaSuccess` correctly points to the `FormHandler` instance.

Alternatively, if `handleRecaptchaSuccess` was an arrow function, it would lexically bind `this`.

# Integration with Modern JavaScript Frameworks React, Vue, Angular



Frameworks introduce their own lifecycle and state management, which can make direct `data-callback` attributes less straightforward.

*   Pitfall: Direct DOM manipulation like setting `data-callback` or `grecaptcha.render` can conflict with how frameworks manage the Virtual DOM or components.
*   Solution React Example - `useEffect` or Custom Hook:
    ```jsx


   import React, { useEffect, useRef, useState } from 'react'.

    const RecaptchaForm =  => {
        const recaptchaRef = useRefnull.


       const  = useStatenull.

        useEffect => {


           if window.grecaptcha && recaptchaRef.current {


               // Ensure grecaptcha is ready and the div exists


               window.grecaptcha.renderrecaptchaRef.current, {
                    sitekey: 'YOUR_SITE_KEY',
                    callback: token => {


                       console.log"React reCAPTCHA token:", token.
                        setRecaptchaTokentoken.
                    },
                    'expired-callback':  => {
                        setRecaptchaTokennull.


                       console.log"reCAPTCHA expired in React".


       }, . // Empty dependency array means this runs once after mount

        const handleSubmit = e => {
            e.preventDefault.
            if recaptchaToken {


               // Send recaptchaToken along with other form data to server


               console.log"Submitting form with token:", recaptchaToken.


               // ... fetch'/api/submit', { method: 'POST', body: JSON.stringify{ token: recaptchaToken, ...formData } }.
            } else {


               alert"Please complete the reCAPTCHA.".

        return 
            <form onSubmit={handleSubmit}>
               {/* Other form fields */}
               <div ref={recaptchaRef}></div> {/* reCAPTCHA will render here */}


               <button type="submit" disabled={!recaptchaToken}>Submit</button>
            </form>
        .

    export default RecaptchaForm.



   // In your main index.html, ensure the reCAPTCHA script is loaded:


   // <script src="https://www.google.com/recaptcha/api.js?onload=onloadRecaptcha&render=explicit" async defer></script>
    // <script>
    //   window.onloadRecaptcha = function {


   //     // This global function runs when grecaptcha API is ready


   //     // Your React app might then mount a component that uses grecaptcha.render
    //   }.
    // </script>


   This example shows using `useRef` to target the DOM element and `useEffect` to manage the `grecaptcha.render` call, ensuring it happens at the correct component lifecycle stage.

Similar patterns apply to Vue using `mounted` hooks and Angular using `ngOnInit`.



By understanding these advanced patterns and common pitfalls, you can deploy a more resilient and integrated reCAPTCHA solution, capable of handling complex scenarios and ensuring your website remains secure from automated threats.

 Frequently Asked Questions

# What is the reCAPTCHA callback function used for?


The reCAPTCHA callback function is a JavaScript function that executes once a user successfully completes a reCAPTCHA challenge.

Its primary purpose is to receive the reCAPTCHA response token, which is then sent to your server for final validation to confirm the user is human.

# How do I find the reCAPTCHA callback function in reCAPTCHA v2?


For reCAPTCHA v2 checkbox or invisible, you typically find the callback function name in the `data-callback` attribute of the `div` element where the reCAPTCHA widget is rendered, e.g., `<div data-callback="myCallback"></div>`. If rendered programmatically, check the `callback` property in the options object passed to `grecaptcha.render`.

# How do I find the reCAPTCHA callback for reCAPTCHA v3?
reCAPTCHA v3 doesn't use a direct `data-callback` attribute. Instead, the "callback" logic is typically found within the `.then` method of the Promise returned by `grecaptcha.execute`. For example: `grecaptcha.execute.thenfunctiontoken { /* your logic here */ }.`.

# Can I have multiple reCAPTCHA widgets on one page with different callbacks?


Yes, you can have multiple reCAPTCHA widgets on one page, but it's best to render them programmatically using `grecaptcha.render` for each widget.

Each call to `render` can specify a unique `callback` function, ensuring independent handling for each reCAPTCHA instance.

# What should I do inside the reCAPTCHA callback function?
Inside the callback function, you should:
1.  Receive the reCAPTCHA response token.


2.  Enable your form's submit button if it was disabled.


3.  Send the reCAPTCHA token, along with your form data, to your server for server-side validation.

# Is server-side validation necessary after the callback fires?


Yes, server-side validation is absolutely necessary and non-negotiable. The client-side token can be bypassed or forged.

Your server must send the token to Google's `siteverify` API to confirm its authenticity, validity, and whether it has been used before.

# What is the `data-expired-callback` attribute?


The `data-expired-callback` attribute for reCAPTCHA v2 specifies a JavaScript function that is called when the reCAPTCHA response token expires typically after about 2 minutes. This allows you to reset the reCAPTCHA widget or prompt the user to re-verify before submitting the form.

# How do I reset reCAPTCHA after an expired token or failed submission?


For reCAPTCHA v2, you can call `grecaptcha.reset` within your `data-expired-callback` function or after a failed form submission.

If using explicit rendering, you might need to pass the widget ID to `grecaptcha.resetwidget_id`. reCAPTCHA v3 automatically handles its own lifecycle.

# Why is my reCAPTCHA callback function not firing?


Common reasons include: incorrect function name in `data-callback`, the function not being in the global scope, JavaScript errors on your page, or the reCAPTCHA API script not being fully loaded when the widget attempts to initialize. Check your browser's developer console for errors.

# What are `grecaptcha.ready` and `onloadCallback`?


`onloadCallback` is a global function specified in the reCAPTCHA API script URL e.g., `?onload=onloadCallback`. It's called once the reCAPTCHA API JavaScript has completely loaded.

`grecaptcha.ready` is a more robust alternative, especially for reCAPTCHA v3 or dynamic content, ensuring that your code interacting with `grecaptcha` runs only when the API is fully initialized.

# Can I use reCAPTCHA with AJAX form submissions?
Yes, you can use reCAPTCHA with AJAX.

In your callback function for v2 or within the `.then` block for v3, you retrieve the token and then include this token in the data payload of your AJAX request to your server for validation.

# What's the difference between reCAPTCHA v2 and v3 in terms of callbacks?
reCAPTCHA v2 uses a direct `data-callback` attribute or `callback` option that fires *after* a user interaction checkbox or invisible. reCAPTCHA v3 provides a score without direct user interaction, and its "callback" is typically the `then` method of a Promise, which receives the token *after* `grecaptcha.execute` is called programmatically.

# How do I pass additional data to my callback function?


The reCAPTCHA API only passes the token to your callback.

If you need to pass additional data, you'll need to use closures if defining the callback dynamically or access elements/data from the DOM or global scope within your callback function.

# What does a low reCAPTCHA v3 score mean?


A low reCAPTCHA v3 score closer to 0.0 indicates that Google's algorithm believes the interaction is more likely from a bot. A high score closer to 1.0 indicates a human.

Your server-side validation should decide what action to take based on the score threshold you set.

# What happens if the reCAPTCHA script fails to load?


If the reCAPTCHA script fails to load, the reCAPTCHA widget will not appear or function.

Your forms might become unusable or submit without reCAPTCHA protection.

It's good practice to have a fallback mechanism or an error message for users if the script doesn't load.

# Should I disable the submit button until reCAPTCHA is complete?


Yes, it's a good practice for reCAPTCHA v2. Keep the submit button disabled by default and enable it only after the `onRecaptchaSuccess` callback fires, indicating the user has completed the challenge.

For reCAPTCHA v3, you can allow submission to trigger the reCAPTCHA execution.

# Where should I put the reCAPTCHA API script tag in my HTML?


It's generally recommended to place the reCAPTCHA API script tag just before the closing `</body>` tag for performance, or in the `<head>` with `async` and `defer` attributes.

Ensure your code that interacts with `grecaptcha` waits for the API to be fully loaded using `onloadCallback` or `grecaptcha.ready`.

# Can reCAPTCHA callbacks interfere with other JavaScript on my page?


Yes, poorly implemented reCAPTCHA callbacks or general JavaScript errors can interfere with other scripts.

Ensure your callback functions are well-defined, error-free, and correctly scoped.

Using `grecaptcha.ready` and proper `onload` handling minimizes conflicts.

# Is reCAPTCHA accessible for users with disabilities?
Google aims to make reCAPTCHA accessible.

reCAPTCHA v2 generally includes audio challenges for visually impaired users.

reCAPTCHA v3 is often completely invisible, making it inherently more accessible.

Always ensure your overall form and page design also follow accessibility best practices.

# How do I debug reCAPTCHA callback issues?


Use your browser's developer tools F12. Check the "Console" tab for JavaScript errors, the "Network" tab to ensure the reCAPTCHA API script is loading correctly, and add `console.log` statements within your callback functions to confirm they are being reached and what values they receive.

How to solve reCAPTCHA v3
0.0
0.0 out of 5 stars (based on 0 reviews)
Excellent0%
Very good0%
Average0%
Poor0%
Terrible0%

There are no reviews yet. Be the first one to write one.

Amazon.com: Check Amazon for Wie man die
Latest Discussions & Reviews:

Leave a Reply

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