﻿function ValidaNumeroCheque(source, args) {
    var Dado, Dig, Mult, Soma, Resto, i;

    if (args.Value.length != 7)
        args.IsValid = false;

    Dado = args.Value.substr(0, 6);    
    Soma = 0;
    Mult = 7;
    
    for (i = 0; i < Dado.length; i++) {
        Soma += Mult * parseInt(Dado.charAt(i));
        Mult--;
    }

    Resto = Soma % 11;

    if (Resto > 1)
        Dig = 11 - Resto;
    else
        Dig = 0;
        
    args.IsValid = Dig == args.Value.substr(6, 1);
}
