1 functionFill (code)//code is the organization code to validate2 {3 4 if(Code.length! = 9)5 {6Alert ("The number of organization code bits is incorrect");7 8 }9 ElseTen { One varPATRN =/^[0-9a-z]+$/; A - if(Patrn.test (CODE) = =false) - { the -Alert ("Organization code can only be a numeric or uppercase Latin alphabet"); - - } + Else - { + varLASTPATRN =/^[0-9x]+$/; A at varCheckcode = code.substring (8, 9); - - if(Lastpatrn.test (checkcode) = =false) - { - -Alert ("The last person in the organization code can only be a numeric or uppercase Latin alphabet: X"); in } - Else to { + varAncode; - varAncodevalue; the varTotal = 0; * varWeightedfactors = [3, 7, 9, 10, 5, 8, 4, 2];//weighting Factor $ varstr = ' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ';Panax Notoginseng for(vari = 0; i < code.length-1; i++) - { the +Ancode = code.substring (i, i + 1); AAncodevalue =Str.indexof (ancode); theTotal = Total + Ancodevalue *Weightedfactors[i]; + } - varLogiccheckcode = 11-total% 11; $ if(Logiccheckcode = = 10) $Logiccheckcode = ' X '; - if(Logiccheckcode = = 11) -Logiccheckcode = ' 0 '; the if(Checkcode! =Logiccheckcode) - {Wuyi theAlert ("Organization Code structure error." The last check code should be: "+logiccheckcode); - } Wu Else - { AboutAlert ("Organization Code is correct); $ } - } - } - } A}
The approximate shelf of code came from the network, I made the changes. If the original person see this code, please contact me to indicate the source of the mark
Reprint please indicate the source
Organization Code of the enterprise JavaScript foot test