jQuery表单验证插件 Validation for Bootstrap

码农软件 · 软件分类 · jQuery表单及相关 · 2019-12-23 13:59:38

软件介绍

首先需要引入 jQuery 和 Bootstrap 库,然后在Js代码中加入下面一行代码。

$('#form').validation();

$('#form') 为jQuery选中你需要验证的 dom 元素,最后只需要在html代码中指定相关的属性即可。

<form class="form-horizontal">
    <div class="control-group">
        <label class="control-label" for="inputEmail">邮箱</label>
        <div class="controls">
            <input type="text" id="inputEmail" check-type="mail" mail-message="邮箱格式不正确!" >
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputPassword">密码</label>
        <div class="controls">
            <input type="password" id="inputPassword" check-type="required" required-message="密码不能为空!" >
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <button type="submit" class="btn">登录</button>
        </div>
    </div>
</form>

其中 check-type 为需要验证的规则,可以绑定多个规则,之间用空格隔开。

其中 required-message 为验证为通过显示的信息,在这里 required-message 的'-'之前为前面定义的验证规则名称。

本文地址:https://www.codercto.com/soft/d/21780.html

The Creative Curve

The Creative Curve

Allen Gannett / Knopf Doubleday Publishing Group / 2018-6-12

Big data entrepreneur Allen Gannett overturns the mythology around creative genius, and reveals the science and secrets behind achieving breakout commercial success in any field. We have been s......一起来看看 《The Creative Curve》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具