<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    JBOSS 點滴

    豐豐的博客

    Jquery Eeay UI Validatebox 常用自定義效驗

    $.extend($.fn.validatebox.defaults.rules, {     
        alpha:
    {     
            validator:function(value,param)
    {     
               
    if (value){     
                    
    return /^[a-zA-Z/u00A1-/uFFFF]*$/.test(value);     
                }
     else {     
                    
    return true;     
                }
         
            }
    ,     
            message:
    '只能輸入字母.'     
        }
    ,     
       alphanum:
    {     
            validator:function(value,param)
    {     
               
    if (value){     
                    
    return /^([a-zA-Z/u00A1-/uFFFF0-9])*$/.test(value);     
                }
     else {     
                    
    return true;     
                }
         
            }
    ,     
            message:
    '只能輸入字母和數(shù)字.'     
        }
    ,     
        positive_int:
    {     
            validator:function(value,param)
    {     
                
    if (value){     
                    
    return /^[0-9]*[1-9][0-9]*$/.test(value);     
                }
     else {     
                    
    return true;     
               }
         
            }
    ,     
            message:
    '只能輸入正整數(shù).'     
        }
    ,     
        numeric:
    {     
            validator:function(value,param)
    {     
                
    if (value){     
                   
    return /^[0-9]*(/.[0-9]+)?$/.test(value);     
                }
     else {     
                    
    return true;     
                }
         
            }
    ,     
            message:
    '只能輸入數(shù)字.'     
        }
    ,     
        chinese:
    {     
            validator:function(value,param)
    {     
            
    if (value){     
                 
    return /[^/u4E00-/u9FA5]/g.test(value);     
            }
     else {     
                
    return true;     
            }
         
        }
    ,     
        message:
    '只能輸入中文'     
    }
         
                 
    }
    );  
      
    $.extend($.fn.validatebox.defaults.rules, 
    {  
        CHS: 
    {  
            validator: function (value, param) 
    {  
                
    return /^[/u0391-/uFFE5]+$/.test(value);  
            }
    ,  
            message: 
    '請輸入漢字'  
        }
    ,  
        ZIP: 
    {  
            validator: function (value, param) 
    {  
                
    return /^[1-9]/d{5}$/.test(value);  
            }
    ,  
            message: 
    '郵政編碼不存在'  
        }
    ,  
        QQ: 
    {  
            validator: function (value, param) 
    {  
                
    return /^[1-9]/d{4,10}$/.test(value);  
            }
    ,  
            message: 
    'QQ號碼不正確'  
        }
    ,  
       mobile: 
    {  
            validator: function (value, param) 
    {  
                
    return /^((/(/d{2,3}/))|(/d{3}/-))?13/d{9}$/.test(value);  
            }
    ,  
            message: 
    '手機號碼不正確'  
        }
    ,  
        loginName: 
    {  
            validator: function (value, param) 
    {  
                
    return /^[/u0391-/uFFE5/w]+$/.test(value);  
            }
    ,  
            message: 
    '登錄名稱只允許漢字、英文字母、數(shù)字及下劃線。'  
        }
    ,  
        safepass: 
    {  
            validator: function (value, param) 
    {  
                
    return safePassword(value);  
            }
    ,  
            message: 
    '密碼由字母和數(shù)字組成,至少6位'  
        }
    ,  
        equalTo: 
    {  
            validator: function (value, param) 
    {  
                
    return value == $(param[0]).val();  
            }
    ,  
            message: 
    '兩次輸入的字符不一至'  
        }
    ,  
        number: 
    {  
            validator: function (value, param) 
    {  
               
    return /^/d+$/.test(value);  
            }
    ,  
            message: 
    '請輸入數(shù)字'  
        }
    ,  
        idcard: 
    {  
            validator: function (value, param) 
    {  
                
    return idCard(value);  
            }
    ,  
            message:
    '請輸入正確的身份證號碼'  
        }
      
    }
    );  
      
    /* 密碼由字母和數(shù)字組成,至少6位 */  
    var safePassword 
    = function (value) {  
        
    return !(/^(([A-Z]*|[a-z]*|/d*|[-_/~!@#/$%/^&/*/./(/)/[/]/{/}<>/?/////'/"]*)|.{0,5})$|/s/.test(value));   
    }  
      
    var idCard = function (value) {  
        if (value.length == 18 && 18 != value.length) return false;  
        var number = value.toLowerCase();  
        var d, sum = 0, v = '10x98765432', w = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], a = '11,12,13,14,15,21,22,23,31,32,33,34,35,36,37,41,42,43,44,45,46,50,51,52,53,54,61,62,63,64,65,71,81,82,91';  
        var re = number.match(/^(/d{2})/d{4}(((/d{2})(/d{2})(/d{2})(/d{3}))|((/d{4})(/d{2})(/d{2})(/d{3}[x/d])))$/);  
        if (re == null || a.indexOf(re[1]) < 0) return false;  
        if (re[2].length == 9) {  
            number = number.substr(0, 6) + '19' + number.substr(6);  
            d = ['19' + re[4], re[5], re[6]].join('-');  
        } else d = [re[9], re[10], re[11]].join('-');  
        if (!isDateTime.call(d, 'yyyy-MM-dd')) return false;  
        for (var i = 0; i < 17; i++) sum += number.charAt(i) * w[i];  
        return (re[2].length == 9 || number.charAt(17) == v.charAt(sum % 11));  
    }  
      
    var isDateTime = function (format, reObj) {  
        format = format || 'yyyy-MM-dd';  
        var input = this, o = {}, d = new Date();  
        var f1 = format.split(/[^a-z]+/gi), f2 = input.split(//D+/g), f3 = format.split(/[a-z]+/gi), f4 = input.split(//d+/g);   
        var len = f1.length, len1 = f3.length;  
        if (len != f2.length || len1 != f4.length) return false;  
        for (var i = 0; i < len1; i++) if (f3[i] != f4[i]) return false;  
        for (var i = 0; i < len; i++) o[f1[i]] = f2[i];  
        o.yyyy = s(o.yyyy, o.yy, d.getFullYear(), 9999, 4);  
        o.MM = s(o.MM, o.M, d.getMonth() + 1, 12);  
        o.dd = s(o.dd, o.d, d.getDate(), 31);  
        o.hh = s(o.hh, o.h, d.getHours(), 24);  
        o.mm = s(o.mm, o.m, d.getMinutes());  
        o.ss = s(o.ss, o.s, d.getSeconds());  
        o.ms = s(o.ms, o.ms, d.getMilliseconds(), 999, 3);  
        if (o.yyyy + o.MM + o.dd + o.hh + o.mm + o.ss + o.ms < 0) return false;  
        if (o.yyyy < 100) o.yyyy += (o.yyyy > 30 ? 1900 : 2000);  
        d = new Date(o.yyyy, o.MM - 1, o.dd, o.hh, o.mm, o.ss, o.ms);  
        var reVal = d.getFullYear() == o.yyyy && d.getMonth() + 1 == o.MM && d.getDate() == o.dd && d.getHours() == o.hh && d.getMinutes() == o.mm && d.getSeconds() == o.ss && d.getMilliseconds() == o.ms;  
        return reVal && reObj ? d : reVal;  
        function s(s1, s2, s3, s4, s5) {  
            s4 = s4 || 60, s5 = s5 || 2;  
            var reVal = s3;  
            if (s1 != undefined && s1 != '' || !isNaN(s1)) reVal = s1 * 1;  
            if (s2 != undefined && s2 != '' && !isNaN(s2)) reVal = s2 * 1;  
            return (reVal == s1 && s1.length != s5 || reVal > s4) ? -10000 : reVal;  
        }  
    };  

    posted on 2013-07-26 23:01 半導體 閱讀(287) 評論(0)  編輯  收藏 所屬分類: Jquery

    主站蜘蛛池模板: 亚洲精品无码一区二区| 亚洲Av永久无码精品三区在线| 毛片亚洲AV无码精品国产午夜| 全部免费毛片在线| av电影在线免费看| 亚洲国产精品成人综合色在线婷婷| 永久免费av无码网站大全| 国产在线精品观看免费观看| 亚洲精品视频在线观看免费 | 亚洲成a人片在线播放| 在线看片免费人成视频久网下载| 亚洲导航深夜福利| 亚洲人成影院在线观看| 免费成人激情视频| 乱爱性全过程免费视频| 亚洲日本一区二区三区| www.亚洲色图| 国产日本一线在线观看免费| 一级毛片aa高清免费观看| 亚洲噜噜噜噜噜影院在线播放| 亚洲人成网站色在线入口| 免费看污成人午夜网站| 久久国产精品免费| 亚洲AV日韩AV无码污污网站| 亚洲理论精品午夜电影| 国产亚洲美女精品久久久2020 | 国产成人高清精品免费软件| a级毛片免费播放| 美国免费高清一级毛片| 亚洲一级免费毛片| 亚洲AV永久无码精品成人| 免费一区二区三区四区五区| 国产人在线成免费视频| 亚洲人成电影网站色| 99xxoo视频在线永久免费观看| 亚洲人成伊人成综合网久久久| 伊伊人成亚洲综合人网7777| 拨牐拨牐x8免费| 毛片无码免费无码播放| 东北美女野外bbwbbw免费| 一级做受视频免费是看美女|