Organization Code of the enterprise JavaScript foot test

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.