jquery较验组织机构编码

//*************************组织机构码较验*************************

          function checkOrganizationCode()

              {

                 var weight = [3, 7, 9, 10, 5, 8, 4, 2];

                 var str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';

                 var reg = /^([0-9A-Z]){8}-[0-9|X]{1}$/;

                 var organizationcode = $("#organizationcode").val().trim();

                 if(organizationcode=="" || organizationcode == null)

                    { 

                        $("#checkorganizationcode").html("<font color='red'>组织机构编码不可以为空</font>");

                        return false;

                    }

                 else if(!reg.test(organizationcode))

                    { 

                        $("#checkorganizationcode").html("<font color='red'>请按格式正确填写组织机构编码,例如:05862390-X</font>");

                        return false;

                    }

                 else 

                    {

                        var sum = 0;

                        for (var i = 0; i < 8; i++) 

                           {

                              sum += str.indexOf(organizationcode.charAt(i)) * weight[i];

                           }

                        var code9 = getCheckCode(sum);

                        if(code9 == organizationcode.charAt(9))

                           {

                              $("#checkorganizationcode").html("");

                              return true;

                           }

                        else

                              $("#checkorganizationcode").html("<font color='red'>您输入的组织结构编码不正确,请仔细检查后输入</font>");

                              return false;     

                    }

              }   

              function getCheckCode(number)

                  {

                      var Remainder = 11 - (number % 11);

                      if( Remainder<10 )

                          {

                             return Remainder

                          }

                      else if(Remainder == 10)

                          {

                             return X;

                          }   

                      else 

                          return 0;

                  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值