简体   繁体   English

Twitter Bootstrap验证不适用于WordPress主题。

[英]Twitter Bootstrap validation not working in WordPress theme.

I have built a theme in WordPress and it works ok but I cannot get Twitter Bootstrap validation to work, been stuck for a few weeks now. 我已经在WordPress中建立了一个主题,它可以正常工作,但是我无法使Twitter Bootstrap验证正常工作,已经停留了几周。 Here's functions.php folder: 这是functions.php文件夹:

<?php

add_theme_support( 'post-thumbnails' );  //Adds thumbnails compatibility to the theme 
// set_post_thumbnail_size( 250, 250 ); // 50 pixels wide by 50 pixels tall, resize mode

function dsm_portfolio_styles() {
    wp_enqueue_style('bootstrap_css', get_template_directory_uri() . '/vendor/bootstrap/css/bootstrap.min.css');
    wp_enqueue_style('style.css', get_template_directory_uri() . '/style.css');
}

add_action('wp_enqueue_scripts', 'dsm_portfolio_styles'); 

function dsm_javascript_scripts() {
    wp_enqueue_script('bootstrap_js', get_template_directory_uri() . '/vendor/bootstrap/js/bootstrap.min.js', array('jquery'), '', true);

    wp_enqueue_script('jqBootstrapValidation', get_template_directory_uri() . '/js/jqBootstrapValidation.js', array('jquery'), '', true );

    wp_enqueue_script('contact_me', get_template_directory_uri() . '/js/contact_me.js', array('jquery'), '', true );

    wp_enqueue_script('freelancer', get_template_directory_uri() . '/js/freelancer.min.js', array('jquery'), '', true );

    wp_enqueue_script('scrollspy', get_template_directory_uri() . '/js/scrollspy.js', array('jquery'), '', true );



}

add_action('wp_enqueue_scripts', 'dsm_javascript_scripts'); 

and form on index.php page: 和index.php页面上的表单:

<!-- Contact Section -->
 <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">
                <!-- To configure the contact form email address, go to mail/contact_me.php and update the email address in the PHP file on line 19. -->
                <!-- The form should work on most web servers, but if the form is not working you may need to configure your web server differently. -->
                <form name="sentMessage" id="contactForm" novalidate action="http://formspree.io/daniel@mobbzys.co.uk" method="POST">
                    <div class="row control-group">
                        <div class="form-group col-xs-12 floating-label-form-group controls">
                            <label for="name">Name</label>
                            <input name="name" 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 for="email">Email Address</label>
                            <input name="email" 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 for="phone">Phone Number</label>
                            <input name="phone" 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 for="message">Message</label>
                            <textarea name="message" 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>

you should add this script in footer. 您应该在页脚中添加此脚本。

<script>
  $(function () { $("input,select,textarea").not("type=submit]").jqBootstrapValidation(); } );
</script>

working fiddle link 工作小提琴链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的Wordpress,Bootstrap主题不适用于JavaScript - My Wordpress, Bootstrap theme is not working with JavaScript Jquery 验证和使用 twitter bootstrap 面板 - Jquery validation and working with twitter bootstrap panels 自定义 Wordpress 主题、Bootstrap IE 8 无法正常工作 - Custom Wordpress Theme, Bootstrap IE 8 not working properly 使用带有 wordpress 自定义主题的 barba.js v2 时,Slick.js、Typewriter.js 等外部脚本无法正常工作。 如何解决它们? - External scripts like Slick.js, Typewriter.js not working when using barba.js v2 with wordpress custom theme. How to solve them? 使用Wordpress主题的ie8和ie9中的Jquery错误。 (对象不支持此属性或方法) - Jquery Error in ie8 and ie9 with Wordpress theme. (Object doesnt support this property or method) 在Twitter Bootstrap模式中进行验证 - Validation in a Twitter Bootstrap modal 使用Django验证Twitter Bootstrap - Validation Twitter Bootstrap with Django 无法在基于Bootstrap的Wordpress主题中使用下拉菜单 - Can't get my dropdown working in a Bootstrap based Wordpress theme bootstrap折叠导航在我的wordpress主题中不起作用 - bootstrap collapse navigation not working in my wordpress theme in mobile 引导主题的选项卡式窗格中的验证 - validation in tabbed pane of bootstrap theme
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM