Hej Alvion
Kan du bruge denne her:
http://www.stigaard.dk/ean2/function ccc13(form) {
factor = 3;
sum = 0;
if (form.numero.value.length!=12){
alert("The ID Number you entered contains only " + form.numero.value.length + " digit(s). " +
"\nThe EAN/UCC-13 ID Number requires that you enter 12 digits." +
"\n\nPlease check your number and try again." +
"\n\nIf you require more assitance, please contact Customer" +
"\nService at 937-435-3870.");
form.cc.value = ""
} else {
for (index = form.numero.value.length; index > 0; --index) {
sum = sum + form.numero.value.substring (index-1, index) * factor;
factor = 4 - factor;
}
leadingdigit(form);
cc = ((1000 - sum) % 10);
form.cc.value = cc;
}
}
function leadingdigit(form) {
if (form.numero.value.substring(0,1) == 0) {
alert("By selecting 0 zero as your first digit, you are indicating" +
"\nthe use of a UCC assigned Company Prefix and Identifying a" +
"\nGlobal Location Number (GLN)");
}
if (form.numero.value.substring(0,1) > 0 ) {
alert("By selecting 1-9 as your first digit, you are" +
"\nindicating the use of an EAN assigned Company" +
"\nPrefix and are identifying GTINs or GLNs");
}
}