zoukankan      html  css  js  c++  java
  • jquery-validate新增校验

     $.validator.addMethod("checkText",function(value,element,params){
            var reg01 = /^[u4e00-u9fa5]+$/;
            return this.optional(element)||(reg01.test(value));
        },"只能输入中文");
        $.validator.addMethod("checkMerchantCode",function(value,element,params){
            var reg01 = /^[a-zA-Z0-9]+$/;
            return this.optional(element)||(reg01.test(value));
        },"只能输入数字和字母");
        $.validator.addMethod("checkPhone",function(value,element,params){
            // var checkEmail = /^[a-z0-9]+@([a-z0-9]+.)+[a-z]{2,4}$/i;
            var reg01 = /^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[0-9]|19[0-9])[0-9]{8}$/;
            var reg02 = /^(0[0-9]{2,3}-)([2-9][0-9]{6,7})+(-[0-9]{1,4})?$/;
            return this.optional(element)||(reg01.test(value)||reg02.test(value));
        },"*请输入正确的手机号或座机号!");
        $.validator.addMethod("checkNumber",function(value,element,params){
            var reg01 = /^d+$|^d+[.]?d+$/;
            return this.optional(element)||(reg01.test(value));
        },"请正确输入数字");
        $.validator.addMethod("checkIdCard",function(value,element,params){
            var reg01 = /(^d{15}$)|(^d{18}$)|(^d{17}(d|X|x)$)/;
            return this.optional(element)||(reg01.test(value));
        },"只能输入数字和X");
        $.validator.addMethod("checkTaxNo",function(value,element,params){
            var reg01 = /^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/;
            return this.optional(element)||(reg01.test(value));
        },"只能输入数字和大写字母、长度只能是15、17、18、20位");
        $.validator.addMethod("checkTaxRate",function(value,element,params){
            var reg01 = /^(0)(.[d]{1,2})?$/;
            return this.optional(element)||(reg01.test(value));
        },"请输入0-1之间的1或2位小数");
        $.validator.addMethod("checkTaxRate2",function(value,element,params){
            var reg01 = /^(0)(.[d]{1,2})?$/;
            var reg02 = "免税";
            return this.optional(element)||(reg01.test(value)||(reg02 == value));
        },"请输入0-1之间的1或2位小数,或"免税"");
        $.validator.addMethod("checkInteger",function(value,element,params){
            var reg01 =  /^[+]{0,1}(d+)$/;
            return this.optional(element)||(reg01.test(value));
        },"请输入整数");
  • 相关阅读:
    BFS模版程序
    7.3 GROUP BY的“新”功能
    《ASP.NET》数据绑定—DropDownList、ListBox
    GPS NEMA 0183协议
    使用Microsoft.Office.Interop.Excel时,64位问题
    HDU 1848(sg博弈) Fibonacci again and again
    Codeforces 559A Gerald's Hexagon 数三角形
    移动mm 话费支付接入过程(ane)
    Android怎样实现毛玻璃效果之Android高级模糊技术
    ECLIPSE android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
  • 原文地址:https://www.cnblogs.com/Lolita-Q/p/15181118.html
Copyright © 2011-2022 走看看