> For the complete documentation index, see [llms.txt](https://docs.toomuchmedia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toomuchmedia.com/nats-admin/sites/further-reading/join-page-captcha.md).

# Join Page CAPTCHA

You only need to set up CAPTCHA on your join template(s), not your gateway template(s), unless you are using the gateway one-step feature.&#x20;

This is the case regardless of the CAPTCHA style you choose.

## Styles

Currently, NATS supports 2 CAPTCHA styles in your join templates.&#x20;

You can change the style by navigating to the Configuration Admin, selecting the Surfer Tab, then setting the **Member Signup Captcha Style** under the [Signup Form section](/nats-admin/configuration/configuration-overview/surfer.md#signup-form).

The current default is 'Image with Letters' for retroactive support. If you are setting CAPTCHA on your join templates for the first time, we recommend using the 'Google reCAPTCHA V2' option.

### Image with Letters

To set up the classic CAPTCHA on your join forms, please add the following code to your join template(s) (if not present already) within the main form (between the \<form>...\</form> tags).

**Basic**

{% code overflow="wrap" %}

```
{if ((!empty($vars.captcha_required) || !empty($errors.captcha)) && ($config.MEMBER_SIGNUP_CAPTCHA_STYLE == 1))}
	<tr>
		<td colspan="2" style="border:none; text-align: center">
			<img src="/captcha_image.php?width=300&height=90" width="300" height="90" /><br />
			<strong>Please fill in the text from the image</strong><br />
			<input class="join_input" type="text" name="signup[captcha:1]" />
			{if !empty($errors.captcha)}
				<br />
				<span>{$errors.captcha}</span>
			{/if}
		</td>
	</tr>
{/if}
```

{% endcode %}

**Stylish**

{% code overflow="wrap" %}

```
{if ((!empty($vars.captcha_required) || !empty($errors.captcha)) && ($config.MEMBER_SIGNUP_CAPTCHA_STYLE == 1))}
	<fieldset>
		<legend>Verification</legend>
		<div class="form_input">
			{if !empty($errors.captcha)}<div class="join_error">{$errors.captcha}</div>{/if}
			<img src="/captcha_image.php?width=300&height=90" width="300" height="90" /><br />
			<label class="memberinfo">Verify Text:</label>
			<input class="join_input" type="text" name="signup[captcha:1]" />
		</div>
	</fieldset>
{/if}
```

{% endcode %}

You can customize the CAPTCHA size by adjusting the width and height attributes of the \<img> tag.&#x20;

{% hint style="info" %}
**Please note:** You will need to change the values in the src attribute (the url width and height variables) as well as the width and height attributes of the \<img> tag.
{% endhint %}

By default, NATS will store the CAPTCHA value in the **ses\_captcha** session variable. You can change the name of the session variable by adding the following form field to your join template.

```
<input type="hidden" name="captcha_key" value="some_text">
```

Given this example, NATS will use the ses\_captcha\_some\_text session variable to store the CAPTCHA value.

### Google reCAPTCHA v2

To set up the Google reCAPTCHA V2 on your join forms, please first [obtain a site key and a secret key from Google](https://www.google.com/recaptcha/admin).&#x20;

Once you have these values, navigate to the Configuration Admin, select the Surfer Tab, then enter these 2 values into the '**Member Signup Google Recaptcha Key**' and the '**Member Signup Google Recaptcha Secret**' fields, respectively.

Please add the following code to your join template(s) (if not present already) between the \<head>...\</head> tags

{% code overflow="wrap" %}

```
{if (!empty($vars.captcha_required) && ($config.MEMBER_SIGNUP_CAPTCHA_STYLE == 2))}<script src="https://www.google.com/recaptcha/api.js" async defer></script>{/if}
```

{% endcode %}

Please add the following code to your join template(s) (if not present already) within the main form (between the \<form>...\</form> tags).

{% code overflow="wrap" %}

```
{if ((!empty($vars.captcha_required) || !empty($errors.captcha)) && ($config.MEMBER_SIGNUP_CAPTCHA_STYLE == 2))}
	<fieldset>
		<legend>Verification</legend>
		<div class="option-padding">
			{if !empty($errors.captcha)}<div class="join_error">{$errors.captcha}</div>{/if}
			<div class="g-recaptcha" style="width: 304px; margin: 0 auto" data-sitekey="{$config.MEMBER_SIGNUP_GOOGLE_RECAPTCHA_KEY}"></div>
		</div>
	</fieldset>
{/if}
```

{% endcode %}

#### NATS Special Options

To use Google reCAPTCHA v2 with any special options, you will need to add additional jQuery code to your $(document).ready() function.

This example is designed so only one recaptcha field is required on your template, and have the recaptcha work for both normal join option form & special option form.

{% code overflow="wrap" %}

```
{literal}
	$("#specialSignupform").submit(function(){
		var g_recaptcha = $('#signupform [name=g-recaptcha-response]').val();
		$('#specialSignupform').append("<input type='hidden' name='g-recaptcha-response' value='" + g_recaptcha + "'>");
	});
{/literal}
```

{% endcode %}

This will also require updating your template's forms to include an id:

Normal form section from (if not already set):

```
<body>
	<div id="container">
		<div id="form">
			<form action="signup.php">
```

To:

```
<body>
	<div id="container">
		<div id="form">
			<form id="signupform" action="signup.php">
```

Special option form section (if not already set):

```
{if $have_special_options}
	<br>
	<form action="signup.php" method="POST">
```

To:

```
{if $have_special_options}
	<br>
	<form id="specialSignupform" action="signup.php" method="POST">
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.toomuchmedia.com/nats-admin/sites/further-reading/join-page-captcha.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
