Answered
Hello all,
I'm trying to find some script that would enable me to add a check digit calculator to my form. More specifically a GTIN+14 barcode and a UPC-A barcode.
I've found alot of online calculators but I'm not quite sure how to extract a javascript from there then incorporate that into my form.
Any help or lead in the right direction will be greatly appreciated.
Thanks,
CLIFF
var sVal = "2468135791234"; // Sample value
var sum = 0;
var factor = 3;
for (var i = sVal.length - 1; i > -1; i--) {
sum += +sVal[i] * factor;
factor = 4 - factor;
}
var check_digit = (sum % 10) ? 10 - (sum % 10) : 0;
app.alert(check_digit);