将验证码添加到响应 Bootstrap 联系表单

deyfvvtc  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(237)

我对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>
xhv8bpkk

xhv8bpkk1#

Google ReCaptcha是一个很好的工具,Google也在准备一个不需要用户输入的Captcha。
要实现ReCaptcha,您需要执行以下操作:
1.创建Google验证码API密钥
1.将代码粘贴到HTML中。基本上是一个div和一些JS。
1.提交表单时验证响应。
您可以按照此处的分步教程进行操作:https://bootstrapious.com/p/bootstrap-recaptcha

相关问题