0

I have set up google reCaptcha on contact us page but i dont know how to check its mandatory on submit for any other way.

2

To do so, you need some custom code, please follow below steps which work for me:

Note: I assume you used jQuery library on your frontend theme

Step-1: On document ready add some custom class to your reCAPTCHA input field:

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery('#recaptcha_response_field').addClass('required-captcha-entry');
})
</script>

Step-2: Initialize Magento VarienForm javascript class object and add new validation rule for reCAPTCHA field:

<script type="text/javascript">
var yourFormValidationObj = new VarienForm('your_form_id');

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

Step-3: On form submit, validate form for required values

<script type="text/javascript">
if(yourFormValidationObj.validator.validate()){
    // Form validate and ready to submit
    jQuery('YOUR_FORM_IDENTIFIER').submit();
} 
</script>

That's, your reCAPTCHA field is become required field and validated before submit the form.

0

You can try this method: Magento Enable Captcha For Contact Us Form

Hope it will help you.

  • Sorry I am using Google captcha . – Ajay Patel Mar 25 '16 at 11:48
  • Are you using reCaptcha Extension? – Umar Ali Mar 25 '16 at 11:51
  • Not extension i am customize and used this. – Ajay Patel Mar 25 '16 at 11:53
  • you can use this extension reCAPTCHA and its free – Umar Ali Mar 25 '16 at 11:55
  • i have try this but not working form e. not display captcha box. i have already set the both key. – Ajay Patel Mar 25 '16 at 11:56

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.