Twitter的Bootstrap表单验证 [英] Twitter's Bootstrap Form Validation

查看:70
本文介绍了Twitter的Bootstrap表单验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何使用Twitter Bootstrap弹出窗口进行jQuery验证通知?

Possible Duplicate:
How to use Twitter Bootstrap popovers for jQuery validation notifications?

尝试使用引导程序样式进行表单验证.

Trying to use bootstrap's styles for form validation.

我正在使用此JavaScript验证程序,该验证程序是为引导程序定制的: https://github.com/ddarren/jQuery-Live-表单验证-Twitter引导程序

I'm using this javascript validator, that was customized for bootstrap: https://github.com/ddarren/jQuery-Live-Form-Validation-For-Twitter-Bootstrap

在头部:

    <link href="bootstrap.css" rel="stylesheet">
    <script src="jquery.validate.js" type="text/javascript">

体内:

    <form id="Form" action="" method="post">
      <div class="control-group">
        <input type="text" class="span3" id="Mobile" placeholder="Mobile
          Phone Number" name="Mobile">
      </div>

      <div class="control-group"> 
        <button type="submit" class="btn btn-primary btn-large">Submit
          </button></p>
      </div>
    </form>

并且它不会使用引导程序的错误样式突出显示字段.有什么想法我要去哪里吗?预先感谢.

And it doesn't highlight the fields with bootstrap's error styles. Any ideas where I'm going wrong? Thanks in advance.

推荐答案

我正在从事类似的工作,所以我想可能会对您有所帮助.
首先, jQuery-Live-Form-Validation-For-Twitter-Bootstrap 库很老(2009年9月).
它使用 jQuery 的版本 1.3.2 (最新版本是1.7.1),并且根本不使用原始的 Bootstrap 文件!
如果您从 github 网站下载了 jQuery-Live-Form-Validation-For-Twitter-Bootstrap (我确定您已完成),则可以轻松地检入 css 文件夹,其中包含该库的作者编写的两个CSS文件.
回答您的问题后,我下载了该库,并粘贴了您的代码,然后它开始工作了.
简单来说,您需要在 head 中保存该文件(以及文件夹中的文件):

I'm working on something similar so I think I might help you.
First of all, jQuery-Live-Form-Validation-For-Twitter-Bootstrap library is quite old (September of 2009).
It uses version 1.3.2 of jQuery (the newest is 1.7.1) and it doesn't use the original Bootstrap files at all!
If you downloaded jQuery-Live-Form-Validation-For-Twitter-Bootstrap (what I am sure you did) from github site you can easily check in css folder that there are two css files written by the author of that library.
Answering to your question, I downloaded that lib and I've pasted your code and... it works.
Simply, you need to have in head this (and that files in folders):

<link rel="stylesheet" type="text/css" href="stylesheets/jquery.validate.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
<script src="lib/jquery/jquery-1.3.2.js" type="text/javascript">
</script>
<script src="javascripts/jquery.validate.js" type="text/javascript">
</script>

最初取自 jQuery-Live-Form-Validation-For-Twitter-Bootstrap 的内容.
如果您真的想使用jQuery进行 Twitter Bootstrap表单验证,我建议您使用组合的 Twitter Bootstrap jQuery验证插件.
我现在正在研究它,它可以正常工作.

what is originally taken from jQuery-Live-Form-Validation-For-Twitter-Bootstrap.
If you really want to have Twitter Bootstrap form validation with jQuery I would like to recommend you using combined Twitter Bootstrap and jQuery Validation Plugin.
I am working on it now and it works perfectly.

这篇关于Twitter的Bootstrap表单验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆