I want to add google captcha on contact us page.





is there any simple widget to call google captcha on form.phtml?


Suppose You have Form Similar to the code below

 <form id="myformId" class="col s12" action=""
        <input placeholder="Name" id="mpfaqs-form-fieldset-input" type="text" name="username">
        <input placeholder="Email" id="mpfaqs-form-fieldset-input" type="text" name="useremail">
            <input placeholder="What is your question" id="mpfaqs-form-fieldset-input-question"
                   type="text" name="userquestion">
    <div class="g-recaptcha" data-sitekey="YOURSITEKEYxxxxx"></div>
        <input class="form-submit" type="Submit" name="" value="Submit a question">
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src='https://www.google.com/recaptcha/api.js?hl=es'></script>

To Validate above Form through javascript we will use the below code you can place it in the same file or create an external file for it and place the code

    ], function($) {
        $(document).on('submit', '#myformId', function(){
            var isSubmit = jQuery(this).valid() && grecaptcha.getResponse() != '';
            if (!isSubmit) {
                alert("Please fill captcha");
            return isSubmit;
  • Thanks for the answer. +1 and accepted :) May 2 '19 at 11:45
  • Excellent and working very fine. +1 Jun 1 '20 at 21:38
  • can you tell how to have invisible captcha for newsletter in magento 2? Jun 1 '20 at 21:38

Magento has a default option for google captcha in contact us page.

Stores -> Configuration -> Customers -> Customer Configuration -> CAPTCHA -> Choose Contact Us under Forms

Refer the screenshot below

  • is that google captcha? May 2 '19 at 11:31
  • Yes, it is. Magento has default option. Magento 2.3 version has google recaptcha May 2 '19 at 11:33
  • yes I have tried, but I don't think this is google captcha :) screencast.com/t/5nKBGA8d May 2 '19 at 11:44
  • Thanks for the answer. +1 :) May 2 '19 at 11:45

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.