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