All pastes #974833 Raw Edit

Mine

public text v1 · immutable
·published 2008-04-07 02:28 UTC
rendered paste body
function clientid()
{
        var field02 = document.pizza.field02.value;
        var left_sum = 0;
        var right_sum = 0;

        if(field02.length != 12)
                return "ClientID must be 12 characters.  ";

        if(field02.charCodeAt(0) != 65 && field02.charCodeAt(0) != 70)
                return "The first character in ClientID must be either an upper case A or F.  ";

        if(field02.charCodeAt(6) != 45)
                return "The Seventh position must be a hyphen (-).  ";

        for(i=1; i<6; i++)
        {
                left_sum += eval(field02.charAt(i));

                if(field02.charCodeAt(i) < 48 || field02.charCodeAt(i) > 57)
                        return "The second through sixth characters must be numeric.  ";
        }

        for(i=7; i<12; i++)
        {
                right_sum += eval(field02.charAt(i));

                if(field02.charCodeAt(i) < 48 || field02.charCodeAt(i) > 57)
                        return "The eighth through twelfth characters must be numeric.  ";
        }

        if(left_sum > right_sum)
                return "The sum of the second through sixth characters must be less than the sum of the eighth through twelfth characters.  ";

        return "";
}