自定义表单验证

1.引入必要的文件

<link href="~/Content/easyui/themes/default/easyui.css" rel="stylesheet" />
<link href="~/Content/easyui/themes/icon.css" rel="stylesheet" />

<script src="~/Content/easyui/js/jquery.min.js"></script>
<script src="~/Content/easyui/js/jquery.easyui.min.js"></script>
<script src="~/Content/easyui/js/easyui-lang-zh_CN.js"></script>


<script src="~/js/easyui-extend-rcm.js"></script>   自定义的文件

2.自定义表单验证

 

(function ($) {
    $.extend($.fn.validatebox.defaults.rules, {
        cardnumber: {
            validator: function (value, param) {
                return /^\d[16]$/.test(value);
            },
            message: '请输入正确的身份证号码'
        },
        checkNum: {
            validator: function (value, param) {
                return /^([0-9]+)$/.test(value);
            },
            message: '请输入整数'
        },
        checkFloat: {
            validator: function (value, param) {
                return /^[+|-]?([0-9]+\.[0-9]+)|[0-9]+$/.test(value);
            },
            message: '请输入合法数字'
        }
    });
})(jQuery);  

 

posted @ 2017-12-11 15:07  fight139  阅读(182)  评论(0编辑  收藏  举报