I am building an item entry form where the user will need to submit a products corresponding UPC (11 or 12 digit upc) with the check digit. I am looking for a way, in caspio, to verify that the check digit is correct.
For example, to calculate the check digit for UPC 82546692620
I will take the sum of all the odd position digits (8+5+6+9+6+0=34)
I will multiply the sum by 3 (34 * 3 = 102)
I will take the sum of all the even position digits (2+5+6+2+2=16)
I will add the result of step 2 with step 3 (102+16=118)
I will divide the sum of step 4 by 10 (118/10=11.8 or 11 remainder 8)
I will take the remainder of step 5 and subtract from 10 (10-8=2)
The resulting check digit for 82546692620 is 2
I have two fields that the user will populate - UPC and UPC Check Digit. I would need to calculate the result above and ensure it is equal to the check digit entered by the user. If not equal, the form should not submit.
Any assistance would be most appreciated and helpful.