Browse Source

Update ean.js

Fixed the way in which the check digit is calculated to allow for the case where the checksum is exactly divisible by 10, to make the check digit 0.  In the previous code the check digit was being returned as 10.
Manish Baxi 11 years ago
parent
commit
b73b511091
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/js/validator/ean.js

+ 1 - 1
src/js/validator/ean.js

@@ -33,7 +33,7 @@
             for (var i = 0; i < length - 1; i++) {
                 sum += parseInt(value.charAt(i)) * weight[i % 2];
             }
-            sum = 10 - sum % 10;
+            sum = (10 - sum % 10) % 10;
             return (sum == value.charAt(length - 1));
         }
     };