Barcode verifier

Hi,

One of my users entered incorrect 13 digit & 14 digit EAN barcodes in different numeric fields on a simple product database, how do I go about verifying this input. any help would be most appreciated.

thanks

Subject: barcode verifier

Basically, the last digit of the code is a “check digit” that can be calculated based on the previous digits. To test the code, you should calculate that digit and compare with the last digit of the code.

This is the algorith for UPC/EAN check digit calculation:

  1. Multiply each digit of the original number by a weighting factor of 1 or 3 as follows: multiply the units digit by 3, the tens digit by 1, the hundreds digit by 3, the thousands digit by 1, and so forth.

  2. Sum the products from step 1.

  3. The check digit is described by the following equation where “sum” is the resulting value of step 2: (10 - (sum modulo 10)) modulo 10

Exemple:

  • Let’t take the following the EAN 13 Barcode number:

    8 4 1 1 0 6 1 4 4 7 5 8 1

The last digit (check digit) = 1

Step 1:

(81)+(43)+(11)+(13)+(01)+(63)+(11)+(43)+(41)+(73)+(51)+(83)

Step 2:

= 109

Step 3:

(109 modulo 10) = 9

10 - (109 modulo 10) = 1 (your check digit)

NOTE: If the result is 10, then apply another modulo 10 operation → check digit will be 0 (zero)

For EAN 14 it is the same, but there are 13 digit to multiply and sum.

Have fun!

Subject: RE: barcode verifier

Hi Radu,

Thanks for the reply

The problem I have is that the check digit has already been applied and the number+checkdigit have been incorrectly entered into a field, I was looking more for any user experience validating the entered number.