zoukankan      html  css  js  c++  java
  • 自定义验证jquery.validate

    js中填写

    $(function() {
        validateSysConfigForm();
        jQuery.validator.addMethod("validateNum", function (value, element, param) {
            var aint = parseInt(value);
            return aint > 0 && (aint+"") == value;
        }, "请填写正整数(>0)");
    });

    表单的验证

    /**
     * 表单验证
     */
    function validateSysConfigForm()
    {
        $('#payMoneyForm').validate({
            rules:{
                payMoney: {
                    required: true,
                    validateNum:true
                }
            },
            messages:{
                payMoney: {
                    required: "请填写停车缴费金额",
                    validateNum: "请填写正整数(>0)"
                }
            },
            errorElement : 'div',
            errorClass : 'help-block',
            focusInvalid : false,
            ignore : "",
    
            highlight : function(e) {
                $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
            },
            success : function(e) {
                $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
                $(e).remove();
            },
            errorPlacement : function(error, element) {
                if(element.is('.select2')) {
                    error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                }
                else error.insertAfter(element.parent());
            },
    
            submitHandler : function(form) {
    
    
                var url = '/base/config/edit.html';
    
                commit(url, '/base/config/editUI.html');
            }
        });
    }
  • 相关阅读:
    利用Linux系统生成随机密码的8种方法
    go语言中ASCII&unicode&utf8由来
    go语言指针
    js设计模式=封装
    python中urllib.request对象案例
    php实现jwt
    python错误捕获练习
    python多线程
    python多进程练习
    http三次握手,四次挥手
  • 原文地址:https://www.cnblogs.com/xuerong/p/5583392.html
Copyright © 2011-2022 走看看