Wufoo:自定义表单Google Recaptcha无法正常工作

时间:2019-11-13 21:50:06

标签: php jquery wordpress wufoo

我创建了一个自定义wufoo表单,但Google Recaptcha无法正常工作。单击提交按钮后,我将重定向到实际的wufoo表单(https://sample.wufoo.com/forms/xxxyyyy/),而不是成功提交该表单。

这是我使用自定义功能wordpress的代码。

function contact_form($atts) {
    $form_hash = 'xxxxx';
    $form_action = 'https://sample.wufoo.com/forms/xxxyyyy/';
    $form_name = 'xxxx222';
    ob_start();
    ?>

    <div class="form-col">
        <form id="<?php echo $form_name; ?>" class="wufoo bvalidate-form" name="<?php echo $form_name; ?>" method="post" action="<?php echo $form_action; ?>" data-bvalidator-validate>
            <div class="form-group">
                <label>Name</label>
                <input type="text" name="Field1" value="" class="form-control" placeholder="Enter Your Name"  data-bvalidator="required,minlength[2]" data-bvalidator-msg="Please enter your full name" />
            </div>
            <div class="form-group">
                <label>ZIP Code</label>
                <input type="number" name="Field2" value="" class="form-control" placeholder="Enter Your ZIP Code" data-bvalidator="number,maxlength[5],minlength[5],required" data-bvalidator-msg="Please enter a valid zip code" />
            </div>

    <div class="form-group">
                <label>&nbsp;</label>
                <div class="g-recaptcha" data-sitekey="sitekey"></div>
<span id="captcha_error"></span>
            </div>

            <div class="form-group-full submit">

                <button type="submit" class="btn btn-primary btn-form">Submit</button>
                <input type="hidden" id="idstamp" name="idstamp" value="<?php echo $form_hash; ?>" />
            </div>
        </form>
    </div>
    </form>
   <?php $output = ob_get_clean();

    return $output;
}

这是我的jquery验证器

<script>
$(document).ready(function(){
$('form').on('submit', function(e) {
  if(grecaptcha.getResponse() == "") {
    e.preventDefault();
    $('#captcha_error').text('Please Check the Box');

  }
});
});
</script>

我在顶部区域添加了recaptcha api.js。

<script src='https://www.google.com/recaptcha/api.js'>

谢谢。

0 个答案:

没有答案
相关问题