Magento – How to add mage_captcha on newsletter form in magento 1.9

captchamagento-1.9newsletter

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>
            </reference>
            <action method="setFormId"><formId>contacts</formId></action>
            <action method="setImgWidth"><width>230</width></action>
            <action method="setImgHeight"><width>50</width></action>
        </block>
    </block>

Best Answer

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

YOUR-PROJECT/app/design/frontend/YOURTHEME/default/template/newsletter/subscribe.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">
    jQuery(document).ready(function(){
        jQuery('#recaptcha_response_field').addClass('required-captcha-entry');
    })
    var yourFormValidationObj = new VarienForm('newsletter-validate-details');

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

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