JavaScript frame number identification/validation function code car frame number verification program _javascript Tips

Source: Internet
Author: User
Algorithm root:
In general, the 9th digit of the vehicle identification code is the inspection bit, which can be indicated by any number or letter "X" in 0-9. The number of other positions and the meaning of the letters may be different, but after the other 16-bit codewords of the VIN code are determined, the test bit of the nineth bit is calculated according to the following method.
First, convert the letters in the other 16 digits to numbers in the following relation:
A=1 B=2 C=3 D=4 E=5 F=6 G=7 H=8 J=1 K=2 L=3 M=4 N=5 P=7 R=9 S=2 T=3 U=4 V=5 W=6 X=7 Y=8 Z=9
Each position has a weighted number:
Location: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17
Weights: 8 7 6 5 4 3 2 10 * 9 8 7 6 5-4 3 2
Finally, the weighted coefficients of each of the 16 bits outside the test bit are multiplied by the corresponding values of the bits, then the products are added together, and divided by 11, the remainder is the value of the test bit. If the remainder is 10, the test bit is the letter "X".
JS Code:
Copy Code code as follows:

<script type= "Text/javascript" >
var Arr = new Array ();
var Brr = new Array ();
arr[' A '] = 1;
arr[' B '] = 2;
arr[' C '] = 3;
arr[' D '] = 4;
arr[' E '] = 5;
arr[' F '] = 6;
arr[' G '] = 7;
arr[' H '] = 8;
arr[' J '] = 1;
arr[' K '] = 2;
arr[' L '] = 3;
arr[' M '] = 4;
arr[' N '] = 5;
arr[' P '] = 7;
arr[' R '] = 9;
arr[' S '] = 2;
arr[' T '] = 3;
arr[' U '] = 4;
arr[' V '] = 5;
arr[' W '] = 6;
arr[' X '] = 7;
arr[' Y '] = 8;
arr[' Z '] = 9;
arr[' 1 '] = 1;
arr[' 2 '] = 2;
arr[' 3 '] = 3;
arr[' 4 '] = 4;
arr[' 5 '] = 5;
arr[' 6 '] = 6;
arr[' 7 '] = 7;
arr[' 8 '] = 8;
arr[' 9 '] = 9;
arr[' 0 '] = 0;
brr[1]=8;
brr[2]=7;
brr[3]=6;
brr[4]=5;
brr[5]=4;
brr[6]=3;
brr[7]=2;
brr[8]=10;
brr[9]=0;
brr[10]=9;
brr[11]=8;
brr[12]=7;
brr[13]=6;
brr[14]=5;
brr[15]=4;
brr[16]=3;
brr[17]=2;
function Getcheckcode (Svin)
{
var skyzf= "ABCDEFGHJKLMNPRSTUVWXYZ1234567890";
var sjyw = ';
var bl = false;
var blkyzf = false;
if (svin.length = 17)
{
var ijqs=0,inttemp=0;
HT = ARR;
HTZM = BRR;
Try
{
for (var i = 0; I <sVIN.length; i++)
{
if (Skyzf.indexof (Svin.substr (i, 1))!=-1)
{
Blkyzf = true;
Ijqs = Ijqs + parseint (ht[svin.substr (i, 1)]) * parseint (htzm[(i + 1)]);
}
Else
{
Blkyzf = false;
Break
}
}
if (BLKYZF)
{
IntTemp = ijqs%11;
if (intTemp = 10)
{
Sjyw = "X";
}
Else
{
Sjyw = Inttemp.tostring ();
}
if (Sjyw = = Svin.substr (8, 1)) BL = true;
}
Else
{
BL = false;
}
}
catch (Err)
{
BL = false;
}
}
return BL;
}
Alert (Getcheckcode ("wvgab97pxcd010692"));
</script>

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.