I just want to know how can I add captcha on mage_newsletter on each page of site. Here my .xml code block for view captcha

  <block type="core/text_list" name="form.additional.info">
        <block type="captcha/captcha" name="captcha">
            <reference name="head">
                <action method="addJs"><file>mage/captcha.js</file></action>
            <action method="setFormId"><formId>contacts</formId></action>
            <action method="setImgWidth"><width>230</width></action>
            <action method="setImgHeight"><width>50</width></action>

I was facing the same issue and I made it solved one extension "Google Invisible reCaptcha"

Wait... I changed few modifications in JS code also.

After installing extension set Site key and secret in admin side and open subscription.phtml


Add code just after Form Tag.

    <div class="g-recaptcha" data-sitekey="YOUR-SITE-KEY"></div>

In the last of file add this JS Snippet.

<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
    var yourFormValidationObj = new VarienForm('newsletter-validate-details');

    Validation.add('required-captcha-entry', ' ', function(v) {
        return !Validation.get('IsEmpty').test(v);

It worked for me. Cheers if it works for you..

  • Could you expand on the one extension "Google Invisible reCaptcha". – Vaishal Patel Aug 8 '18 at 10:22
  • Does this extension work on localhost? – aravind May 10 '19 at 5:29
  • Yes @aravind, it works. In case if you would like to run Captcha in Localhost you need to pass localhost in the trusted URL under Google Developer Account. 1. Go to your google reCaptcha admin panel 2. Add localhost & to domains of a new site like the following image – Nidhishanker Modi May 10 '19 at 10:01
  • 1
    @Nidhishanker Modi Ok let me try this solution.. – aravind May 10 '19 at 11:41
  • 1
    @MagentoUser I have added validation in my js code. Validation.add('required-captcha-entry', ' ', function(v) { return !Validation.get('IsEmpty').test(v); }) Make sure there are not two different google captcha forms on same form. – Nidhishanker Modi Jun 11 '20 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.