Form Tools
Recaptcha error message placement - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Recaptcha error message placement (/showthread.php?tid=437)



Recaptcha error message placement - cdcalvert - Jan 12th, 2010

How can I place the recaptcha error message at the top of the form (in the same place as the validation error messages appear) rather than within the recaptcha box? I think the user will miss that and be confused. Any ideas?
Thanks!


RE: Recaptcha error message placement - Ben - Jan 16th, 2010

Yeah... I agree. Let me look at this and I'll get back to you later today.

- Ben


RE: Recaptcha error message placement - Ben - Jan 16th, 2010

Heya,

I looked through the code and you can fluff to make the error message appear wherever you want. Here's how the code works.

The ft_api_process_form() function does all the heavy lifting for API forms. It handles updating the form submission values, redirecting to the next page, and handling incorrectly entered reCAPTCHAs.

If the reCAPTCHA is entered incorrectly, it sets a $g_api_recaptcha_error global variable and stays on the same page. The ft_api_display_captcha() function checks to see if that variable is set then output the error.

So what you can do is catch that variable earlier in the page, e.g. the top, and just output it there. For example:

PHP Code:
<?php if (!empty($g_api_recaptcha_error)) { ?>
  <div>Error message here! (<?=$g_api_recaptcha_error?>)</div>
<?php ?>

If you don't want that error message to appear by the reCAPTCHA as well, just empty the variable value as well:

PHP Code:
<?php if (!empty($g_api_recaptcha_error)) { ?>
  <div>Error message here! (<?=$g_api_recaptcha_error?>)</div>
  <?php $g_api_recaptcha_error ""?>
<?php 
?>

Sorry it's a bit of a hack, but it's not TOO bad...!

- Ben


RE: Recaptcha error message placement - Clauddam - May 17th, 2020

Whenever you try to enter in the different forums then you have to follow the numerous instructions. Although, it is said that essaywriter.org reviews are helping all the users to make them aware.