Work need to use id authentication, but also support check 15 and 18.
I am a lazy hands, ask colleagues have ready-made functions available, colleague googled, throw me a   Asp - vbscript version of the function.
but I'm over here is the client-side javascript, so use change   VBS - >Js
it redone found pretty good, also found that   Vbscript is really long-winded, wrote more than 50 lines, I change to js  Only 11 lines.
of course, and I was completely is refers to the vbscript repetitive, anonymous of the VBS write this code is a tang's monk character...

to release   Vbscript code,      

<Script  Language="vbscript" > 

'functions: check the id card number  
Function  CheckCardId (e)    
        ArrVerifyCode =  Split (" 1, 0, x, 9,8,7,6,5,4,3,2 ",  , "")    
        Wi =  Split (" 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 ",  , "")    
        Checker =  Split (" 1,9,8,7,6,5,4,3,2,1,1 ",  , "")    

        If  Len (e)   <  15   Or  Len (e)  =  16   Or  Len (e)  =  17   Or  Len (e)   >  18   Then   
                CheckCardId=  "Id with   15   or 18"    
                CheckCardId =  False   
                Exit  Function   
        End  If   

        Dim  Ai   
        If  Len (e)  =  18   Then   
                Ai =  Mid (e,   1,   17)    
        ElseIf  Len (e)  =  15   Then   
                Ai =  E   
                Ai =  Left (Ai,   6)   &  "19"   &  Mid (Ai,   7,   9)    
        End  If   

        If  Not  IsNumeric (Ai)   Then   
                CheckCardId=  "Id except the last one, must be numeric!"                    
                Exit  Function   
        End  If   
        Dim  StrYear,   StrMonth,   StrDay   
        StrYear =  CInt (Mid (Ai,   7,   4))    
        StrMonth =  CInt (Mid (Ai,   11,   2))    
        StrDay =  CInt (Mid (Ai,   13,   2))    
        BirthDay =  Trim (strYear)   +   "-"   +   Trim (strMonth)   +   "-"   +   Trim (strDay)    
        If  IsDate (BirthDay)   Then   
                If  DateDiff (" yyyy ", Now, BirthDay) <- 140   Or  Cdate (BirthDay) >The date (s)   Then                   
                        CheckCardId=  "Id input error!"    
                        Exit  Function   
                End  If   
                If  StrMonth  >  12   Or  StrDay  >  31   Then   
                        CheckCardId=  "Id input error!"    
                        Exit  Function   
                End  If   
        Else   
                CheckCardId=  "Id input error!"    
                Exit  Function   
        End  If   
        Dim  I,   TotalmulAiWi   
        For  I =  0   To  16    
                TotalmulAiWi =  TotalmulAiWi  +   CInt (Mid (Ai,   i  +   1,   1))   *   Wi (I)    
        Next   
        Dim  ModValue   
        ModValue =  TotalmulAiWi  Mod  11    
        Dim  StrVerifyCode   
        StrVerifyCode =  ArrVerifyCode (modValue)    
        Ai =  Ai  &  StrVerifyCode     
        CheckCardId =  Ai 

        If  Len (e)  =  18   And  E  <>  Ai  Then   
                CheckCardId=  "Id input error!"    
                Exit  Function   
        End  If   
End  Function   
</script>  

to release   Version of the javascript code to the

function  CheckId (pId) { 
//check the id card number   O Go_Rush (shun)   From  http://ashun.cnblogs.com&nbsp;

        Var  ArrVerifyCode =  (1, 0, "x", 9,8,7,6,5,4,3,2];  
        Var  Wi =  ,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 [7];  
        Var  Checker =  ,9,8,7,6,5,4,3,2,1,1 [1];  

        If (pId) length !=  15   &&  pId. Length !=  18)         Return  "Id with   15   or 18";  

        Var  Ai=pId. The length==18   ?     PId. The substring (0, 2)       :       PId. Slice (0, 6) + "19" + pId. Slice (June 16th);  

        If  (!/^ \ d + $/test (Ai))     Return  "Id except the last one, must be numeric!" ;  

        Var  Yyyy=Ai. Slice (6, 10)   ,     Mm=Ai. Slice (10, 12) 1     ,     Dd=Ai. Slice (12, 14);  

        Var  D=new  The Date (yyyy, mm, dd)   ,     Now=new  The Date ();  
          Var  Year=d.g etFullYear ()   ,     Mon=d.g etMonth ()   ,   Day=d.g etDate ();  

        If  (year!=yyyy  | |   mon!=mm  | |   day!=dd  | |   d> now  | |   year<1940)   Return  "Id input error!" ;           For (var  I=0, ret=0; i<17; i++)     Ret +=Ai. CharAt (I) * Wi [I];          
        Ai +=arrVerifyCode [ret  %=11];            

        Return  PId. Length ==18   &&  PId  !=  Ai? "Id input error!" : Ai;                  
};  

as for the principle of identification algorithm, please refer to:     http://www.google.com/

in the end, according to the id card number pick up     Province, birthday, gender is simple

<Script  Language="javascript" > 
var  Id="342201570202003"    

//according to take id card   Province, birthday, gender     O Go_Rush (shun)   From  http://ashun.cnblogs.com/&nbsp;
Function  GetInfo (id) { 
        Var  arr=[null,null,null,null,null,null,null,null,null,null,null,"北京","天津","河北","山西","内蒙古" 
             ,null,null,null,null,null,"辽宁","吉林","黑龙江",null,null,null,null,null,null,null,"上海" 
             ,"江苏","浙江","安微","福建","江西","山东",null,null,null,"河南","湖北","湖南","广东","广西","海南" 
             ,null,null,null,"重庆","四川","贵州","云南","西藏",null,null,null,null,null,null,"陕西","甘肃" 
             ,"青海","宁夏","新疆",null,null,null,null,null,"台湾",null,null,null,null,null,null,null,null 
             ,null,"香港","澳门",null,null,null,null,null,null,null,null,"国外"] 
        Id=checkId (id)  
        If  (isNaN (id))   Return  "The wrong id number"          
        Var  Id=String (id),     Prov=arr [id. Slice (0, 2)]     ,     Sex=id. Slice (14 or 17) % 2?     "Male"   :   "Female"  
        Var  Birthday=(new  Date (id. Slice (6, 10)  ,   id. The slice   (10, 12) - 1,   id. The slice (12, 14))). The toLocaleDateString ()    
        Return  [prov, birthday, sex]      
}  

alert (getInfo (id))    
</script>  

the above code can take to the provinces, to get to a specific city, please look at my another essay,
code only take the id card number I and several colleagues test once, if there is a Bug, please point out the


This concludes the body part