码迷,mamicode.com
首页 > 其他好文 > 详细

数据验证

时间:2017-03-31 16:48:23      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:输入   box   success   参数   address   var   require   contacts   number   

<script>
    //数据验证参数配置
    $.validator.setDefaults({
        highlight: function (e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function (e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function (e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "m-b-none"
    })
    //数据验证 业务逻辑
    $(function () {
        var e = "<i class=‘fa fa-times-circle‘></i> ";
        $("#signupForm").validate({
            rules: {
                CityID: "required",
                ClassName: "required",
                ComName: "required",
                LogisticsRange: "required",
                ContactsName: "required",
                Position: "required",
                PhoneNumber: "required",
                Address: "required"
            },
            messages: {
                CityID: e + "请选择物业公司",
                ClassName: e + "请输入类别名称",
                ComName: e + "请输入物流公司名称",
                LogisticsRange: e + "请选择相关物流业务经营范围",
                ContactsName: e + "请输入联系人",
                Position: e + "请输入职业",
                PhoneNumber: e + "请输入手机号",
                Address: e + "请输入住址",
            }
            , submitHandler: function () {//执行
                AddorUpdate()
            }
        })
    })
</script>

数据验证

标签:输入   box   success   参数   address   var   require   contacts   number   

原文地址:http://www.cnblogs.com/zlbb/p/6651911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!