将验证码添加到响应式引导程序联系表单

问题描述 投票:2回答:1

我对bootstrap很新。我有一个正常工作的联系表格。但是,我想在表单中添加验证码以帮助消除不需要的垃圾邮件。如何将填充码添加到我现有的表单或表单中的任何其他“你是人”选项(即简单的复选框工作)并使其响应为当前表单?以下是我的表单的代码:

 <section id="contact">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h2>Contact Me</h2>
                <hr class="star-primary">
            </div>
        </div>
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2">
                 <form name="sentMessage" id="contactForm" novalidate>
                    <div class="row control-group">
                        <div class="form-group col-xs-12 floating-label-form-group controls">
                            <label>Name</label>
                            <input type="text" class="form-control" placeholder="Name" id="name" required data-validation-required-message="Please enter your name.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="row control-group">
                        <div class="form-group col-xs-12 floating-label-form-group controls">
                            <label>Email Address</label>
                            <input type="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="row control-group">
                        <div class="form-group col-xs-12 floating-label-form-group controls">
                            <label>Phone Number</label>
                            <input type="tel" class="form-control" placeholder="Phone Number" id="phone" required data-validation-required-message="Please enter your phone number.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <div class="row control-group">
                        <div class="form-group col-xs-12 floating-label-form-group controls">
                            <label>Message</label>
                            <textarea rows="5" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>
                    <br>
                    <div id="success"></div>
                    <div class="row">
                        <div class="form-group col-xs-12">
                            <button type="submit" class="btn btn-success btn-lg">Send</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
php forms twitter-bootstrap
1个回答
0
投票

谷歌ReCaptcha是一个很好的工具,谷歌也准备一个Captcha,不需要用户输入。

要实现ReCaptcha,您需要执行以下操作:

  1. 创建Google ReCaptcha API密钥
  2. 将代码粘贴到HTML中。基本上是一个div和一些JS。
  3. 提交表单时验证响应。

您可以按照以下分步教程进行操作:https://bootstrapious.com/p/bootstrap-recaptcha

© www.soinside.com 2019 - 2024. All rights reserved.