2 * Return true, if the value is a valid vehicle identification number (VIN).
4 * Works with all kind of text inputs.
6 * @example <input type="text" size="20" name="VehicleID" class="{required:true,vinUS:true}" />
7 * @desc Declares a required input element whose value must be a valid vehicle identification number.
9 * @name $.validator.methods.vinUS
11 * @cat Plugins/Validate/Methods
13 $.validator
.addMethod("vinUS", function(v
) {
14 if (v
.length
!== 17) {
18 var LL
= [ "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ],
19 VL
= [ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 7, 9, 2, 3, 4, 5, 6, 7, 8, 9 ],
20 FL
= [ 8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2 ],
24 for (i
= 0; i
< 17; i
++) {
26 d
= v
.slice(i
, i
+ 1);
33 for (n
= 0; n
< LL
.length
; n
++) {
34 if (d
.toUpperCase() === LL
[n
]) {
37 if (isNaN(cdv
) && n
=== 8) {
54 }, "The specified vehicle identification number (VIN) is invalid.");